25#ifndef JAU_BASIC_TYPES_HPP_
26#define JAU_BASIC_TYPES_HPP_
34#include <system_error>
36#include <condition_variable>
123 bool milli_sleep(uint64_t td_ms, const
bool ignore_irq=true) noexcept;
202 bool sleep_for(const
fraction_i64& relative_time, const
bool monotonic=true, const
bool ignore_irq=true) noexcept;
221 const
bool monotonic=true) noexcept;
259 std::cv_status
wait_for(std::condition_variable& cv, std::unique_lock<std::mutex>& lock, const
fraction_timespec& relative_time,
260 const
bool monotonic=true) noexcept;
298 std::cv_status
wait_for(std::condition_variable& cv, std::unique_lock<std::mutex>& lock, const
fraction_i64& relative_time,
299 const
bool monotonic=true) noexcept;
301 std::
string threadName(const std::thread::
id id) noexcept;
309 #define E_FILE_LINE __FILE__,__LINE__
316 std::string backtrace_;
321 ExceptionBase(std::string &&
type, std::string
const& m,
const char* file,
int line)
noexcept;
333 const std::string&
backtrace() const noexcept {
return backtrace_; }
344 virtual const char*
what() const noexcept {
394 :
ExceptionBase(
"OutOfMemoryError", m, file, line), bad_alloc() {}
396 const char*
what() const noexcept
override {
418 const
char*
what() const noexcept
override {
424 LogicError(std::string &&
type, std::string
const& m,
const char* file,
int line) noexcept
428 LogicError(std::string
const& m,
const char* file,
int line) noexcept
429 :
LogicError(
"LogicErrorStd", m, file, line) {}
438 const
char*
what() const noexcept
override {
458 const
char*
what() const noexcept
override {
470 :
IndexOutOfBoundsError(file, line,
"IndexOutOfBoundsError",
"Index "+std::to_string(index)+
", data length "+std::to_string(length)) {}
472 IndexOutOfBoundsError(
const std::string& msg,
const std::size_t index,
const std::size_t length,
const char* file,
int line) noexcept
473 :
IndexOutOfBoundsError(file, line,
"IndexOutOfBoundsError", msg+
": index "+std::to_string(index)+
", data length "+std::to_string(length)) {}
476 :
IndexOutOfBoundsError(file, line,
"IndexOutOfBoundsError",
"Index "+index_s+
", data length "+length_s) {}
478 IndexOutOfBoundsError(
const std::size_t index,
const std::size_t count,
const std::size_t length,
const char* file,
int line) noexcept
479 :
IndexOutOfBoundsError(file, line,
"IndexOutOfBoundsError",
"Index "+std::to_string(index)+
", count "+std::to_string(count)+
", data length "+std::to_string(length)) {}
481 const char*
what() const noexcept
override {
495 const char*
what() const noexcept
override {
509 const char*
what() const noexcept
override {
516 IOError(std::string
const& m,
const char* file,
int line,
const std::error_code& ec = std::io_errc::stream) noexcept
519 const char*
what() const noexcept
override {
563 mask |= 1_u32 << (nr & 31);
570 mask |= ~(1_u32 << (nr & 31));
577 return mask & (1_u32 << (nr & 31));
584 mask |= 1_u64 << (nr & 63);
591 mask |= ~(1_u64 << (nr & 63));
598 return mask & (1_u64 << (nr & 63));
const std::string & backtrace() const noexcept
Returns optional whole backtrace.
const std::string & whole_message() const noexcept
Returns brief message and optional whole backtrace, i.e.
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
const std::string & brief_message() const noexcept
Returns brief message.
virtual const char * what() const noexcept
IOError(std::string const &m, const char *file, int line, const std::error_code &ec=std::io_errc::stream) noexcept
const char * what() const noexcept override
IllegalArgumentError(std::string &&type, std::string const &m, const char *file, int line) noexcept
const char * what() const noexcept override
IllegalArgumentError(std::string const &m, const char *file, int line) noexcept
const char * what() const noexcept override
IllegalStateError(std::string &&type, std::string const &m, const char *file, int line) noexcept
IllegalStateError(std::string const &m, const char *file, int line) noexcept
IndexOutOfBoundsError(const std::string &msg, const std::size_t index, const std::size_t length, const char *file, int line) noexcept
IndexOutOfBoundsError(const std::size_t index, const std::size_t count, const std::size_t length, const char *file, int line) noexcept
IndexOutOfBoundsError(const std::size_t index, const std::size_t length, const char *file, int line) noexcept
const char * what() const noexcept override
IndexOutOfBoundsError(const std::string &index_s, const std::string &length_s, const char *file, int line) noexcept
IndexOutOfBoundsError(const char *file, int line, std::string &&type, std::string const &m) noexcept
InternalError(std::string const &m, const char *file, int line) noexcept
LogicErrorBase(std::string &&type, std::string const &m, const char *file, int line) noexcept
~LogicErrorBase() noexcept override=default
LogicError(std::string &&type, std::string const &m, const char *file, int line) noexcept
const char * what() const noexcept override
LogicError(std::string const &m, const char *file, int line) noexcept
~LogicError() noexcept override=default
NotImplementedException(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
~RuntimeExceptionBase() noexcept override=default
RuntimeExceptionBase(std::string &&type, std::string const &m, const char *file, int line) noexcept
RuntimeException(std::string const &m, const char *file, int line) noexcept
const char * what() const noexcept override
~RuntimeException() noexcept override=default
RuntimeException(std::string &&type, std::string const &m, const char *file, int line) noexcept
RuntimeSystemExceptionBase(std::string &&type, const std::error_code &ec, std::string const &m, const char *file, int line) noexcept
~RuntimeSystemExceptionBase() noexcept override=default
const std::error_code & code() const noexcept
RuntimeSystemException(const std::error_code &ec, std::string const &m, const char *file, int line) noexcept
const char * what() const noexcept override
~RuntimeSystemException() noexcept override=default
RuntimeSystemException(std::string &&type, const std::error_code &ec, std::string const &m, const char *file, int line) noexcept
UnsupportedOperationException(std::string const &m, const char *file, int line) noexcept
fraction_timespec getWallClockTime() noexcept
Returns current wall-clock real-time since Unix Epoch 00:00:00 UTC on 1970-01-01.
fraction_timespec getMonotonicTime() noexcept
Returns current monotonic time since Unix Epoch 00:00:00 UTC on 1970-01-01.
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.
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.
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...
std::string threadName(const std::thread::id id) noexcept
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.
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.
Timespec structure using int64_t for its components in analogy to struct timespec_t on 64-bit platfor...
A 128-bit packed uint8_t data array.