jaulib v1.3.0
Jau Support Library (C++, Java, ..)
basic_types.hpp
Go to the documentation of this file.
1/*
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2020-2024 Gothel Software e.K.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25#ifndef JAU_BASIC_TYPES_HPP_
26#define JAU_BASIC_TYPES_HPP_
27
28#include <cstring>
29#include <string>
30#include <memory>
31#include <cstdint>
32#include <vector>
33#include <type_traits>
34#include <iostream>
35
36#include <jau/cpp_lang_util.hpp>
39
40#include <jau/int_types.hpp>
41#include <jau/int_math.hpp>
42
43#include <jau/byte_util.hpp>
44#include <jau/string_util.hpp>
45
47#include <jau/fraction_type.hpp>
48
49namespace jau {
50
51 /**
52 * \ingroup Fractions
53 *
54 * Returns current monotonic time since Unix Epoch `00:00:00 UTC on 1970-01-01`.
55 *
56 * Returned fraction_timespec is passing machine precision and range of the underlying API.
57 *
58 * See fraction_timespec::to_fraction_i64() of how to measure duration in high range and precision:
59 * <pre>
60 * fraction_timespec t0 = getMonotonicTime();
61 * // do something
62 *
63 * // Exact duration
64 * fraction_timespec td_1 = getMonotonicTime() - t0;
65 *
66 * // or for durations <= 292 years
67 * fraction_i64 td_2 = (getMonotonicTime() - t0).to_fraction_i64();
68 * </pre>
69 *
70 * This is in stark contract to counting nanoseconds in int64_t which only lasts until `2262-04-12`,
71 * since INT64_MAX is 9'223'372'036'854'775'807 for 9'223'372'036 seconds or 292 years.
72 *
73 * Monotonic time shall be used for high-performance measurements of durations,
74 * since the underlying OS shall support fast calls.
75 *
76 * @see fraction_timespec
77 * @see fraction_timespec::to_fraction_i64()
78 * @see getWallClockTime()
79 */
80 fraction_timespec getMonotonicTime() noexcept;
81
82 /**
83 * \ingroup Fractions
84 *
85 * Returns current wall-clock real-time since Unix Epoch `00:00:00 UTC on 1970-01-01`.
86 *
87 * Returned fraction_timespec is passing machine precision and range of the underlying API.
88 *
89 * Wall-Clock time shall be used for accurate measurements of the actual time only,
90 * since the underlying OS unlikely supports fast calls.
91 *
92 * @see fraction_timespec
93 * @see fraction_timespec::to_fraction_i64()
94 * @see getMonotonicTime()
95 */
96 fraction_timespec getWallClockTime() noexcept;
97
98 /**
99 * Returns current monotonic time in milliseconds.
100 */
101 uint64_t getCurrentMilliseconds() noexcept;
102
103 /**
104 * Returns current wall-clock system `time of day` in seconds since Unix Epoch
105 * `00:00:00 UTC on 1 January 1970`.
106 */
107 uint64_t getWallClockSeconds() noexcept;
108
109 /**
110 * millisecond sleep using high precision monotonic timer,
111 * useful for one-shot delays (only).
112 *
113 * Consider using jau::sleep_until or jau::sleep_for
114 * utilizing absolute target time sleep when waiting
115 * for an event, overcoming clock re-adjustments.
116 *
117 * @param td_ms duration to sleep in milliseconds
118 * @param ignore_irq continue sleep when interrupted by a signal if true, defaults to true
119 * @return true if completed waiting, otherwise false for interruption or error
120 */
121 bool milli_sleep(uint64_t td_ms, const bool ignore_irq=true) noexcept;
122
123 /**
124 * sleep using high precision monotonic timer,
125 * useful for one-shot delays (only).
126 *
127 * Consider using jau::sleep_until or jau::sleep_for
128 * utilizing absolute target time sleep when waiting
129 * for an event, overcoming clock re-adjustments.
130 *
131 * @param relative_time an object of type fraction_timespec representing the time to sleep
132 * @param ignore_irq continue sleep when interrupted by a signal if true, defaults to true
133 * @return true if completed waiting, otherwise false for interruption or error
134 */
135 bool sleep(const fraction_timespec& relative_time, const bool ignore_irq=true) noexcept;
136
137 /**
138 * sleep_until causes the current thread to block until the specific time is reached.
139 *
140 * Method works similar to std::this_thread::sleep_until(), but utilizes fraction_timespec instead of `int64_t nanoseconds counter`
141 * for maintaining high-precision and infinite range.
142 *
143 * Implementation also uses ::clock_nanosleep(), with absolute time and either
144 * monotonic- or wall-clok time depending on given monotonic flag.
145 * This instead of ::nanosleep() with undefined clock-type and interruptions.
146 *
147 * @param absolute_time an object of type fraction_timespec representing the time when to stop waiting
148 * @param monotonic if true, implementation uses the fast and steady monotonic clock (default), otherwise the wall-clock
149 * @param ignore_irq continue sleep when interrupted by a signal if true, defaults to true
150 * @return true if completed waiting, otherwise false for interruption or error
151 * @see sleep_until()
152 * @see sleep_for()
153 * @see wait_until()
154 * @see wait_for()
155 */
156 bool sleep_until(const fraction_timespec& absolute_time, const bool monotonic=true, const bool ignore_irq=true) noexcept;
157
158 /**
159 * sleep_for causes the current thread to block until a specific amount of time has passed.
160 *
161 * Implementation calls sleep_until() passing absolute time derived via getMonotonicTime() or getWallClockTime(), see:
162 * <pre>
163 * fraction_timespec absolute_time = ( monotonic ? getMonotonicTime() : getWallClockTime() ) + relative_time;
164 * </pre>
165 *
166 * Method works similar to std::this_thread::sleep_until(), but utilizes fraction_timespec instead of `int64_t nanoseconds counter`
167 * for maintaining high-precision and infinite range.
168 *
169 * @param relative_time an object of type fraction_timespec representing the the maximum time to spend waiting
170 * @param monotonic if true, implementation uses the fast and steady monotonic clock (default), otherwise the wall-clock
171 * @param ignore_irq continue sleep when interrupted by a signal if true, defaults to true
172 * @return true if completed waiting, otherwise false for interruption or error
173 * @see sleep_until()
174 * @see sleep_for()
175 * @see wait_until()
176 * @see wait_for()
177 */
178 bool sleep_for(const fraction_timespec& relative_time, const bool monotonic=true, const bool ignore_irq=true) noexcept;
179
180 /**
181 * sleep_for causes the current thread to block until a specific amount of time has passed.
182 *
183 * Implementation calls sleep_until() passing absolute time derived via getMonotonicTime() or getWallClockTime(), see:
184 * <pre>
185 * fraction_timespec absolute_time = ( monotonic ? getMonotonicTime() : getWallClockTime() ) + relative_time;
186 * </pre>
187 *
188 * Method works similar to std::this_thread::sleep_until(), but utilizes fraction_timespec instead of `int64_t nanoseconds counter`
189 * for maintaining high-precision and infinite range.
190 *
191 * @param relative_time an object of type fraction_i64 representing the the maximum time to spend waiting, which is limited to 292 years if using nanoseconds fractions.
192 * @param monotonic if true, implementation uses the fast and steady monotonic clock (default), otherwise the wall-clock
193 * @param ignore_irq continue sleep when interrupted by a signal if true, defaults to true
194 * @return true if completed waiting, otherwise false for interruption or error
195 * @see sleep_until()
196 * @see sleep_for()
197 * @see wait_until()
198 * @see wait_for()
199 */
200 bool sleep_for(const fraction_i64& relative_time, const bool monotonic=true, const bool ignore_irq=true) noexcept;
201
202 /**
203 * wait_until causes the current thread to block until the condition variable is notified, a specific time is reached, or a spurious wakeup occurs.
204 *
205 * Method works similar to std::condition_variable::wait_until(), but utilizes fraction_timespec instead of `int64_t nanoseconds counter`
206 * for maintaining high-precision and infinite range.
207 *
208 * @param cv std::condition_variable instance
209 * @param lock an object of type std::unique_lock<std::mutex>, which must be locked by the current thread
210 * @param absolute_time an object of type fraction_timespec representing the time when to stop waiting
211 * @param monotonic if true, implementation uses the fast and steady monotonic clock (default), otherwise the wall-clock
212 * @return std::cv_status::timeout if the relative timeout specified by rel_time expired, std::cv_status::no_timeout otherwise.
213 * @see sleep_until()
214 * @see sleep_for()
215 * @see wait_until()
216 * @see wait_for()
217 */
218 std::cv_status wait_until(std::condition_variable& cv, std::unique_lock<std::mutex>& lock, const fraction_timespec& absolute_time,
219 const bool monotonic=true) noexcept;
220
221 /**
222 * wait_for causes the current thread to block until the condition variable is notified, a specific amount of time has passed, or a spurious wakeup occurs.
223 *
224 * Implementation calls wait_until() passing absolute time derived via getMonotonicTime() or getWallClockTime(), see:
225 * <pre>
226 * fraction_timespec absolute_time = ( monotonic ? getMonotonicTime() : getWallClockTime() ) + relative_time;
227 * </pre>
228 *
229 * Method works similar to std::condition_variable::wait_for(), but utilizes fraction_timespec instead of `int64_t nanoseconds counter`
230 * for maintaining high-precision and infinite range.
231 *
232 * When using a condition predicate loop to ensure no spurious wake-up preemptively ends waiting for the condition variable event or timeout,
233 * it is always recommended to use wait_until() using the absolute timeout time computed once before said loop. Example from latch::wait_for():
234 * <pre>
235 std::unique_lock<std::mutex> lock(mtx_cd);
236 const fraction_timespec timeout_time = getMonotonicTime() + timeout_duration;
237 while( 0 < count ) {
238 std::cv_status s = wait_until(cv, lock, timeout_time);
239 if( 0 == count ) {
240 return true;
241 }
242 if( std::cv_status::timeout == s ) {
243 return false;
244 }
245 }
246 * </pre>
247 * @param cv std::condition_variable instance
248 * @param lock an object of type std::unique_lock<std::mutex>, which must be locked by the current thread
249 * @param relative_time an object of type fraction_timespec representing the the maximum time to spend waiting
250 * @param monotonic if true, implementation uses the fast and steady monotonic clock (default), otherwise the wall-clock
251 * @return std::cv_status::timeout if the relative timeout specified by rel_time expired, std::cv_status::no_timeout otherwise.
252 * @see sleep_until()
253 * @see sleep_for()
254 * @see wait_until()
255 * @see wait_for()
256 */
257 std::cv_status wait_for(std::condition_variable& cv, std::unique_lock<std::mutex>& lock, const fraction_timespec& relative_time,
258 const bool monotonic=true) noexcept;
259
260 /**
261 * wait_for causes the current thread to block until the condition variable is notified, a specific amount of time has passed, or a spurious wakeup occurs.
262 *
263 * Implementation calls wait_until() passing absolute time derived via getMonotonicTime() or getWallClockTime(), see:
264 * <pre>
265 * fraction_timespec absolute_time = ( monotonic ? getMonotonicTime() : getWallClockTime() ) + relative_time;
266 * </pre>
267 *
268 * Method works similar to std::condition_variable::wait_for(), but utilizes fraction_timespec instead of `int64_t nanoseconds counter`
269 * for maintaining high-precision and infinite range.
270 *
271 * When using a condition predicate loop to ensure no spurious wake-up preemptively ends waiting for the condition variable event or timeout,
272 * it is always recommended to use wait_until() using the absolute timeout time computed once before said loop. Example from latch::wait_for():
273 * <pre>
274 std::unique_lock<std::mutex> lock(mtx_cd);
275 const fraction_timespec timeout_time = getMonotonicTime() + timeout_duration;
276 while( 0 < count ) {
277 std::cv_status s = wait_until(cv, lock, timeout_time);
278 if( 0 == count ) {
279 return true;
280 }
281 if( std::cv_status::timeout == s ) {
282 return false;
283 }
284 }
285 * </pre>
286 * @param cv std::condition_variable instance
287 * @param lock an object of type std::unique_lock<std::mutex>, which must be locked by the current thread
288 * @param relative_time an object of type fraction_i64 representing the the maximum time to spend waiting, which is limited to 292 years if using nanoseconds fractions.
289 * @param monotonic if true, implementation uses the fast and steady monotonic clock (default), otherwise the wall-clock
290 * @return std::cv_status::timeout if the relative timeout specified by rel_time expired, std::cv_status::no_timeout otherwise.
291 * @see sleep_until()
292 * @see sleep_for()
293 * @see wait_until()
294 * @see wait_for()
295 */
296 std::cv_status wait_for(std::condition_variable& cv, std::unique_lock<std::mutex>& lock, const fraction_i64& relative_time,
297 const bool monotonic=true) noexcept;
298
299 /**
300 // *************************************************
301 // *************************************************
302 // *************************************************
303 */
304
305 #define E_FILE_LINE __FILE__,__LINE__
306
308 private:
309 std::string msg_;
310 std::string backtrace_;
311 std::string what_;
312
313 protected:
314 ExceptionBase(std::string type, std::string const& m, const char* file, int line) noexcept;
315
316 public:
317 virtual ~ExceptionBase() noexcept = default;
318
319 ExceptionBase(const ExceptionBase &o) = default;
321 ExceptionBase& operator=(const ExceptionBase &o) = default;
322 ExceptionBase& operator=(ExceptionBase &&o) = default;
323
324 const std::string& message() const noexcept { return msg_; }
325 const std::string& backtrace() const noexcept { return backtrace_; }
326
327 /** Allow conversion to `const std::string&`, as required by Catch2's `REQUIRE_THROWS_MATCHES` */
328 operator const std::string& () const noexcept { return message(); };
329
330 virtual const char* what() const noexcept {
331 return what_.c_str(); // return std::runtime_error::what();
332 }
333
334 std::ostream& operator<<(std::ostream& out) noexcept {
335 return out << what_;
336 }
337 };
338
339 class OutOfMemoryError : public std::bad_alloc, public ExceptionBase {
340 public:
341 OutOfMemoryError(std::string const& m, const char* file, int line)
342 : bad_alloc(), ExceptionBase("OutOfMemoryError", m, file, line) {}
343
344 const char* what() const noexcept override {
345 return ExceptionBase::what(); // return std::runtime_error::what();
346 }
347 };
348
349 class RuntimeException : public std::exception, public ExceptionBase {
350 protected:
351 RuntimeException(std::string type, std::string const& m, const char* file, int line) noexcept
352 : exception(), ExceptionBase(std::move(type), m, file, line) {}
353
354 public:
355 RuntimeException(std::string const& m, const char* file, int line) noexcept
356 : RuntimeException("RuntimeException", m, file, line) {}
357
358 ~RuntimeException() noexcept override = default;
359
362 RuntimeException& operator=(const RuntimeException& o) = default;
363 RuntimeException& operator=(RuntimeException&& o) = default;
364
365 const char* what() const noexcept override {
366 return ExceptionBase::what();
367 }
368 };
369
371 public:
372 InternalError(std::string const& m, const char* file, int line) noexcept
373 : RuntimeException("InternalError", m, file, line) {}
374 };
375
377 public:
378 NotImplementedError(std::string const& m, const char* file, int line) noexcept
379 : RuntimeException("NotImplementedError", m, file, line) {}
380 };
381
383 public:
384 NullPointerException(std::string const& m, const char* file, int line) noexcept
385 : RuntimeException("NullPointerException", m, file, line) {}
386 };
387
389 public:
390 IllegalArgumentException(std::string const& m, const char* file, int line) noexcept
391 : RuntimeException("IllegalArgumentException", m, file, line) {}
392 };
393
395 public:
396 IllegalStateException(std::string const& m, const char* file, int line) noexcept
397 : RuntimeException("IllegalStateException", m, file, line) {}
398 };
399
401 public:
402 UnsupportedOperationException(std::string const& m, const char* file, int line) noexcept
403 : RuntimeException("UnsupportedOperationException", m, file, line) {}
404 };
405
407 public:
408 IndexOutOfBoundsException(const std::size_t index, const std::size_t length, const char* file, int line) noexcept
409 : RuntimeException("IndexOutOfBoundsException", "Index "+std::to_string(index)+", data length "+std::to_string(length), file, line) {}
410
411 IndexOutOfBoundsException(const std::string& index_s, const std::string& length_s, const char* file, int line) noexcept
412 : RuntimeException("IndexOutOfBoundsException", "Index "+index_s+", data length "+length_s, file, line) {}
413
414 IndexOutOfBoundsException(const std::size_t index, const std::size_t count, const std::size_t length, const char* file, int line) noexcept
415 : RuntimeException("IndexOutOfBoundsException", "Index "+std::to_string(index)+", count "+std::to_string(count)+", data length "+std::to_string(length), file, line) {}
416 };
417
418 class IOError : public RuntimeException {
419 public:
420 IOError(std::string const& m, const char* file, int line) noexcept
421 : RuntimeException("IOError", m, file, line) {}
422 };
423
424
425 /**
426 // *************************************************
427 // *************************************************
428 // *************************************************
429 */
430
431 /** \addtogroup Integer
432 *
433 * @{
434 */
435
436 inline void set_bit_uint32(const uint8_t nr, uint32_t &mask)
437 {
438 using namespace jau::int_literals;
439 if( nr > 31 ) { throw IndexOutOfBoundsException(nr, 32, E_FILE_LINE); }
440 mask |= 1_u32 << (nr & 31);
441 }
442
443 inline void clear_bit_uint32(const uint8_t nr, uint32_t &mask)
444 {
445 using namespace jau::int_literals;
446 if( nr > 31 ) { throw IndexOutOfBoundsException(nr, 32, E_FILE_LINE); }
447 mask |= ~(1_u32 << (nr & 31));
448 }
449
450 inline uint32_t test_bit_uint32(const uint8_t nr, const uint32_t mask)
451 {
452 using namespace jau::int_literals;
453 if( nr > 31 ) { throw IndexOutOfBoundsException(nr, 32, E_FILE_LINE); }
454 return mask & (1_u32 << (nr & 31));
455 }
456
457 inline void set_bit_uint64(const uint8_t nr, uint64_t &mask)
458 {
459 using namespace jau::int_literals;
460 if( nr > 63 ) { throw IndexOutOfBoundsException(nr, 64, E_FILE_LINE); }
461 mask |= 1_u64 << (nr & 63);
462 }
463
464 inline void clear_bit_uint64(const uint8_t nr, uint64_t &mask)
465 {
466 using namespace jau::int_literals;
467 if( nr > 63 ) { throw IndexOutOfBoundsException(nr, 64, E_FILE_LINE); }
468 mask |= ~(1_u64 << (nr & 63));
469 }
470
471 inline uint64_t test_bit_uint64(const uint8_t nr, const uint64_t mask)
472 {
473 using namespace jau::int_literals;
474 if( nr > 63 ) { throw IndexOutOfBoundsException(nr, 64, E_FILE_LINE); }
475 return mask & (1_u64 << (nr & 63));
476 }
477
478 /**
479 // *************************************************
480 // *************************************************
481 // *************************************************
482 */
483
484 /**
485 * Merge the given 'uuid16' into a 'base_uuid' copy at the given little endian 'uuid16_le_octet_index' position.
486 * <p>
487 * The given 'uuid16' value will be added with the 'base_uuid' copy at the given position.
488 * </p>
489 * <pre>
490 * base_uuid: 00000000-0000-1000-8000-00805F9B34FB
491 * uuid16: DCBA
492 * uuid16_le_octet_index: 12
493 * result: 0000DCBA-0000-1000-8000-00805F9B34FB
494 *
495 * LE: low-mem - FB349B5F8000-0080-0010-0000-ABCD0000 - high-mem
496 * ^ index 12
497 * LE: uuid16 -> value.data[12+13]
498 *
499 * BE: low-mem - 0000DCBA-0000-1000-8000-00805F9B34FB - high-mem
500 * ^ index 2
501 * BE: uuid16 -> value.data[2+3]
502 * </pre>
503 */
504 uint128dp_t merge_uint128(uint16_t const uuid16, uint128dp_t const & base_uuid, nsize_t const uuid16_le_octet_index);
505
506 /**
507 * Merge the given 'uuid32' into a 'base_uuid' copy at the given little endian 'uuid32_le_octet_index' position.
508 * <p>
509 * The given 'uuid32' value will be added with the 'base_uuid' copy at the given position.
510 * </p>
511 * <pre>
512 * base_uuid: 00000000-0000-1000-8000-00805F9B34FB
513 * uuid32: 87654321
514 * uuid32_le_octet_index: 12
515 * result: 87654321-0000-1000-8000-00805F9B34FB
516 *
517 * LE: low-mem - FB349B5F8000-0080-0010-0000-12345678 - high-mem
518 * ^ index 12
519 * LE: uuid32 -> value.data[12..15]
520 *
521 * BE: low-mem - 87654321-0000-1000-8000-00805F9B34FB - high-mem
522 * ^ index 0
523 * BE: uuid32 -> value.data[0..3]
524 * </pre>
525 */
526 uint128dp_t merge_uint128(uint32_t const uuid32, uint128dp_t const & base_uuid, nsize_t const uuid32_le_octet_index);
527
528 /**@}*/
529
530} // namespace jau
531
532/** \example test_intdecstring01.cpp
533 * This C++ unit test validates the jau::to_decstring implementation
534 */
535
536#endif /* JAU_BASIC_TYPES_HPP_ */
#define E_FILE_LINE
const std::string & backtrace() const noexcept
ExceptionBase(std::string type, std::string const &m, const char *file, int line) noexcept
std::ostream & operator<<(std::ostream &out) noexcept
virtual ~ExceptionBase() noexcept=default
virtual const char * what() const noexcept
const std::string & message() const noexcept
IOError(std::string const &m, const char *file, int line) noexcept
IllegalArgumentException(std::string const &m, const char *file, int line) noexcept
IllegalStateException(std::string const &m, const char *file, int line) noexcept
IndexOutOfBoundsException(const std::size_t index, const std::size_t length, const char *file, int line) noexcept
IndexOutOfBoundsException(const std::string &index_s, const std::string &length_s, const char *file, int line) noexcept
IndexOutOfBoundsException(const std::size_t index, const std::size_t count, const std::size_t length, const char *file, int line) noexcept
InternalError(std::string const &m, const char *file, int line) noexcept
NotImplementedError(std::string const &m, const char *file, int line) noexcept
NullPointerException(std::string const &m, const char *file, int line) noexcept
OutOfMemoryError(std::string const &m, const char *file, int line)
const char * what() const noexcept override
RuntimeException(std::string const &m, const char *file, int line) noexcept
const char * what() const noexcept override
RuntimeException(std::string type, std::string const &m, const char *file, int line) noexcept
~RuntimeException() noexcept override=default
UnsupportedOperationException(std::string const &m, const char *file, int line) noexcept
std::string to_string(const alphabet &v) noexcept
Definition: base_codec.hpp:97
fraction_timespec getWallClockTime() noexcept
Returns current wall-clock real-time since Unix Epoch 00:00:00 UTC on 1970-01-01.
Definition: basic_types.cpp:58
fraction_timespec getMonotonicTime() noexcept
Returns current monotonic time since Unix Epoch 00:00:00 UTC on 1970-01-01.
Definition: basic_types.cpp:52
fraction< int64_t > fraction_i64
fraction using int64_t as integral type
uint_fast32_t nsize_t
Natural 'size_t' alternative using uint_fast32_t as its natural sized type.
Definition: int_types.hpp:53
void set_bit_uint32(const uint8_t nr, uint32_t &mask)
uint128dp_t merge_uint128(uint16_t const uuid16, uint128dp_t const &base_uuid, nsize_t const uuid16_le_octet_index)
Merge the given 'uuid16' into a 'base_uuid' copy at the given little endian 'uuid16_le_octet_index' p...
void set_bit_uint64(const uint8_t nr, uint64_t &mask)
void clear_bit_uint32(const uint8_t nr, uint32_t &mask)
uint64_t test_bit_uint64(const uint8_t nr, const uint64_t mask)
uint32_t test_bit_uint32(const uint8_t nr, const uint32_t mask)
void clear_bit_uint64(const uint8_t nr, uint64_t &mask)
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
Definition: backtrace.hpp:32
std::cv_status wait_for(std::condition_variable &cv, std::unique_lock< std::mutex > &lock, const fraction_timespec &relative_time, const bool monotonic=true) noexcept
wait_for causes the current thread to block until the condition variable is notified,...
uint64_t getWallClockSeconds() noexcept
Returns current wall-clock system time of day in seconds since Unix Epoch 00:00:00 UTC on 1 January 1...
Definition: basic_types.cpp:71
std::cv_status wait_until(std::condition_variable &cv, std::unique_lock< std::mutex > &lock, const fraction_timespec &absolute_time, const bool monotonic=true) noexcept
wait_until causes the current thread to block until the condition variable is notified,...
bool sleep_until(const fraction_timespec &absolute_time, const bool monotonic=true, const bool ignore_irq=true) noexcept
sleep_until causes the current thread to block until the specific time is reached.
bool sleep(const fraction_timespec &relative_time, const bool ignore_irq=true) noexcept
sleep using high precision monotonic timer, useful for one-shot delays (only).
bool milli_sleep(uint64_t td_ms, const bool ignore_irq=true) noexcept
millisecond sleep using high precision monotonic timer, useful for one-shot delays (only).
uint64_t getCurrentMilliseconds() noexcept
Returns current monotonic time in milliseconds.
Definition: basic_types.cpp:64
bool sleep_for(const fraction_timespec &relative_time, const bool monotonic=true, const bool ignore_irq=true) noexcept
sleep_for causes the current thread to block until a specific amount of time has passed.
STL namespace.
A 128-bit packed uint8_t data array.
Definition: int_types.hpp:114