Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::core Namespace Reference

General-purpose building blocks and platform abstraction layer. More...

Classes

union  AlignMax
 Maximum aligned data unit. More...
 
class  AlignOps
 Alignment operations. More...
 
class  AlignedStorage
 Fixed-size maximum-aligned storage. More...
 
class  ArenaAllocation
 Allocation policy for objects allocated using IArena. More...
 
class  PoolAllocation
 Allocation policy for objects allocated using IPool. More...
 
class  CustomAllocation
 Allocation policy for objects with custom deallocation function. More...
 
class  ManualAllocation
 Allocation policy for objects that does not have automatic deallocation. More...
 
class  Array
 Dynamic array. More...
 
class  Atomic
 Atomic integer. Provides sequential consistency. For a fine-grained memory order control, see AtomicOps. More...
 
class  Atomic< T * >
 Atomic pointer. Provides sequential consistency. For a fine-grained memory order control, see AtomicOps. More...
 
class  Buffer
 Fixed-size dynamically-allocated byte buffer. More...
 
struct  CsvEntry
 CSV entry. Corresponds to one line in output file. More...
 
struct  CsvConfig
 CSV write configuration. More...
 
class  CsvDumper
 Asynchronous CSV dumper. Writes entries to CSV file from background thread. Recommended to be used from a single thread. More...
 
class  EndianOps
 Endian operations. More...
 
class  GlobalDestructor
 Allows to determine if global library destruction was initiated. More...
 
class  Hashmap
 Intrusive hash table. More...
 
class  HashmapImpl
 Intrusive hash table internal implementation. More...
 
struct  HashmapData
 Hashmap node internal data. More...
 
class  HashmapNode
 Base class for Hashmap element. More...
 
class  HeapArena
 Heap arena implementation. More...
 
class  IArena
 Memory arena interface. More...
 
class  IPool
 Memory pool interface. More...
 
class  LimitedArena
 Decorator around IArena to make it memory limited. More...
 
class  LimitedPool
 Decorator around IPool to make it memory limited. More...
 
class  List
 Intrusive doubly-linked list. More...
 
class  ListImpl
 Intrusive doubly-linked list implementation class. Handles List infrastructure independent of templated type for List. Ownership handling is left to the main List class. More...
 
struct  ListData
 List node internal data. More...
 
class  ListNode
 Base class for List element. More...
 
struct  LogMessage
 Log message. More...
 
class  Logger
 Logger. More...
 
class  MemoryLimiter
 Memory limiter. This class can be used to keep track of memory being consumed. This is done through the acquire and release methods. The class is used within classes such as LimitedPool, LimitedArena. More...
 
class  MemoryOps
 Memory operations. More...
 
class  MovStats
 Rolling window moving average and variance. More...
 
class  MpscQueue
 Thread-safe lock-free node-based intrusive multi-producer single-consumer queue. More...
 
class  MpscQueueImpl
 Multi-producer single-consumer queue internal implementation class. More...
 
struct  MpscQueueData
 MpscQueue node internal data. More...
 
class  MpscQueueNode
 Base class for MpscQueue element. More...
 
class  NonCopyable
 Base class for non-copyable objects. More...
 
class  NoopArenaImpl
 Arena implementation that just fails all allocations. Can be used with containers that have embedded capacity and arena, but we want them to use only embedded capacity. More...
 
class  Optional
 Optionally constructed object. More...
 
class  SharedPtr
 Shared ownership intrusive pointer. More...
 
struct  RefCountedOwnership
 Reference counted object ownership. More...
 
struct  NoOwnership
 No ownership. More...
 
class  Printer
 Printer. More...
 
class  RateLimiter
 Rate limiter. More...
 
class  RefCounted
 Base class for object with reference counter. More...
 
class  RefCountedImpl
 Implementation class for reference counter. More...
 
class  RingQueue
 Queue on continuous memory buffer. More...
 
class  ScopedLock
 RAII mutex lock. More...
 
class  ScopedPtr
 Unique ownrship pointer. More...
 
class  Seqlock
 Seqlock. More...
 
class  SeqlockImpl
 Seqlock implementation class. More...
 
class  SlabPool
 Memory pool. More...
 
class  SlabPoolImpl
 Memory pool implementation class. More...
 
class  Slice
 Slice. More...
 
class  SpscByteBuffer
 Thread-safe lock-free single-producer single-consumer circular buffer of byte chunks. More...
 
class  SpscRingBuffer
 Thread-safe lock-free single-producer single-consumer circular buffer of copyable objects. More...
 
class  StringBuffer
 String buffer. More...
 
class  StringBuilder
 String builder. More...
 
class  StringList
 Dynamic list of strings. More...
 
class  LogBackend
 Log backend. More...
 
class  AtomicOps
 Atomic operations. This wrapper exists because on non-C11 compilers we use another implementation. More...
 
class  Semaphore
 Semaphore. More...
 
class  Cond
 Condition variable. More...
 
class  CrashHandler
 Crash handler. More...
 
class  errno_to_str
 Convert errno to string. More...
 
class  Mutex
 Mutex. More...
 
class  Singleton
 Singleton. More...
 
class  TempFile
 Temporary file. More...
 
class  Thread
 Base class for thread objects. More...
 
class  Ticker
 Ticker. More...
 
class  Timer
 Thread-safe timer. More...
 

Typedefs

typedef SharedPtr< BufferBufferPtr
 Buffer smart pointer. More...
 
typedef size_t hashsum_t
 Hash type. More...
 
typedef void(* LogHandler) (const LogMessage &message, void **args)
 Log handler. More...
 
typedef uint32_t seqlock_version_t
 Type for holding seqlock value version. Version is changed each value update. May wrap. More...
 
typedef int64_t nanoseconds_t
 Nanoseconds. More...
 

Enumerations

enum  HeapArenaGuard { HeapArena_LeakGuard = (1 << 0) , HeapArena_OverflowGuard = (1 << 1) , HeapArena_OwnershipGuard = (1 << 2) }
 Heap arena guards. More...
 
enum  { HeapArena_DefaultGuards = (HeapArena_OverflowGuard | HeapArena_OwnershipGuard) }
 Default heap arena guards. Leak guard is disabled by default, because in C API leaks may be caused by user (e.g. if context wasn't closed before program exit). We don't want to turn bugs in user code into panics, only bugs in our own code should cause panics. More...
 
enum  ColorsMode { ColorsAuto , ColorsEnabled , ColorsDisabled }
 Colors mode. More...
 
enum  LocationMode { LocationEnabled , LocationDisabled }
 Location mode. More...
 
enum  SlabPoolGuard { SlabPool_LeakGuard = (1 << 0) , SlabPool_OverflowGuard = (1 << 1) , SlabPool_OwnershipGuard = (1 << 2) }
 Memory pool guards. More...
 
enum  { SlabPool_DefaultGuards }
 Default memory pool guards. More...
 
enum  Color {
  Color_None , Color_None , Color_White , Color_Gray ,
  Color_Red , Color_Green , Color_Yellow , Color_Blue ,
  Color_Magenta , Color_Cyan
}
 Color ID. More...
 
enum  Color {
  Color_None , Color_None , Color_White , Color_Gray ,
  Color_Red , Color_Green , Color_Yellow , Color_Blue ,
  Color_Magenta , Color_Cyan
}
 Color ID. More...
 
enum  clock_t { ClockMonotonic , ClockUnix }
 Clock identifier. More...
 
enum  { UuidLen = 36 }
 

Functions

void print_backtrace_full ()
 Print backtrace to stderr. More...
 
void print_backtrace_safe ()
 Print backtrace to stderr (emergency mode). More...
 
const char * demangle_symbol (const char *mangled, char *&demangled_buf, size_t &demangled_size)
 Demangle symbol name. More...
 
uint16_t ntoh16u (uint16_t v)
 Network to host byte order (unsigned 16-bit). More...
 
int16_t ntoh16s (int16_t v)
 Network to host byte order (signed 16-bit). More...
 
uint32_t ntoh32u (uint32_t v)
 Network to host byte order (unsigned 32-bit). More...
 
int32_t ntoh32s (int32_t v)
 Network to host byte order (signed 32-bit). More...
 
uint64_t ntoh64u (uint64_t v)
 Network to host byte order (unsigned 64-bit). More...
 
int64_t ntoh64s (int64_t v)
 Network to host byte order (signed 64-bit). More...
 
uint16_t hton16u (uint16_t v)
 Host to network byte order (unsigned 16-bit). More...
 
int16_t hton16s (int16_t v)
 Host to network byte order (signed 16-bit). More...
 
uint32_t hton32u (uint32_t v)
 Host to network byte order (unsigned 32-bit). More...
 
int32_t hton32s (int32_t v)
 Host to network byte order (signed 32-bit). More...
 
uint64_t hton64u (uint64_t v)
 Host to network byte order (unsigned 64-bit). More...
 
int64_t hton64s (int64_t v)
 Host to network byte order (signed 64-bit). More...
 
uint32_t fast_random ()
 Get a random integer from a non cryptographically secure, but fast PRNG. Thread-safe. More...
 
uint32_t fast_random_range (uint32_t from, uint32_t to)
 Get a random integer from a non cryptographically secure, but fast PRNG. Thread-safe. More...
 
double fast_random_gaussian ()
 Get a random double from a non cryptographically secure, but fast PRNG. Thread-safe. More...
 
hashsum_t hashsum_int (int16_t)
 Compute hash of 16-bit integer. More...
 
hashsum_t hashsum_int (uint16_t)
 Compute hash of 16-bit integer. More...
 
hashsum_t hashsum_int (int32_t)
 Compute hash of 32-bit integer. More...
 
hashsum_t hashsum_int (uint32_t)
 Compute hash of 32-bit integer. More...
 
hashsum_t hashsum_int (int64_t)
 Compute hash of 64-bit integer. More...
 
hashsum_t hashsum_int (uint64_t)
 Compute hash of 64-bit integer. More...
 
template<class T >
hashsum_t hashsum_int (T t)
 Compute hash of an integer. This fallback is needed for the cases when the overloads above do not cover all builtin types. E.g. if none of the overloads above covers unsigned long or unsigned long long. More...
 
hashsum_t hashsum_str (const char *str)
 Compute hash of zero-terminated string. More...
 
hashsum_t hashsum_mem (const void *data, size_t size)
 Compute hash of byte range. More...
 
void hashsum_add (hashsum_t &hash, const void *data, size_t size)
 Incrementally compute hash of memory chunks. On first invocation, hash should be zero. More...
 
void panic (const char *module, const char *file, int line, const char *format,...)
 Print error message and terminate program gracefully. More...
 
ROC_ATTR_NODISCARD bool parse_duration (const char *string, nanoseconds_t &result)
 Parse duration from string. More...
 
ROC_ATTR_NODISCARD bool parse_size (const char *string, size_t &result)
 Parse size from string. More...
 
void print_memory (const uint8_t *data, size_t size)
 Print memory. More...
 
void print_memory (const uint16_t *data, size_t size)
 Print memory. More...
 
void print_memory (const uint32_t *data, size_t size)
 Print memory. More...
 
void print_memory (const uint64_t *data, size_t size)
 Print memory. More...
 
void print_memory (const int8_t *data, size_t size)
 Print memory. More...
 
void print_memory (const int16_t *data, size_t size)
 Print memory. More...
 
void print_memory (const int32_t *data, size_t size)
 Print memory. More...
 
void print_memory (const int64_t *data, size_t size)
 Print memory. More...
 
void print_memory (const float *data, size_t size)
 Print memory. More...
 
void print_memory (const double *data, size_t size)
 Print memory. More...
 
void print_memory_slice (const uint8_t *inner, size_t inner_size, const uint8_t *outer, size_t outer_size)
 Print memory slice. More...
 
void print_memory_slice (const uint16_t *inner, size_t inner_size, const uint16_t *outer, size_t outer_size)
 Print memory slice. More...
 
void print_memory_slice (const uint32_t *inner, size_t inner_size, const uint32_t *outer, size_t outer_size)
 Print memory slice. More...
 
void print_memory_slice (const uint64_t *inner, size_t inner_size, const uint64_t *outer, size_t outer_size)
 Print memory slice. More...
 
void print_memory_slice (const int8_t *inner, size_t inner_size, const int8_t *outer, size_t outer_size)
 Print memory slice. More...
 
void print_memory_slice (const int16_t *inner, size_t inner_size, const int16_t *outer, size_t outer_size)
 Print memory slice. More...
 
void print_memory_slice (const int32_t *inner, size_t inner_size, const int32_t *outer, size_t outer_size)
 Print memory slice. More...
 
void print_memory_slice (const int64_t *inner, size_t inner_size, const int64_t *outer, size_t outer_size)
 Print memory slice. More...
 
void print_memory_slice (const float *inner, size_t inner_size, const float *outer, size_t outer_size)
 Print memory slice. More...
 
void print_memory_slice (const double *inner, size_t inner_size, const double *outer, size_t outer_size)
 Print memory slice. More...
 
bool seqlock_version_is_valid (seqlock_version_t ver)
 Check if this is a valid seqlock version. Returns false if seqlock version corresponds to intermediate state that should never be seen by seqlock user. More...
 
template<class T1 , class T2 >
bool operator== (const SharedPtr< T1 > &a, const SharedPtr< T2 > &b)
 Equality check. More...
 
template<class T1 , class T2 >
bool operator!= (const SharedPtr< T1 > &a, const SharedPtr< T2 > &b)
 Equality check. More...
 
bool console_supports_colors ()
 Check if colors can be used. More...
 
void console_println (const char *format,...)
 Print line. More...
 
void console_println (Color color, const char *format,...)
 Print line (with color). More...
 
void cpu_relax ()
 CPU pause instruction. More...
 
void die_fast (int code)
 Terminate program. More...
 
void die_gracefully (const char *message, bool full_backtrace)
 Terminate program with error message and backtrace. More...
 
nanoseconds_t timestamp (clock_t clock)
 Get current timestamp in nanoseconds. More...
 
void sleep_until (clock_t clock, nanoseconds_t timestamp)
 Sleep until the specified absolute time point has been reached. More...
 
void sleep_for (clock_t clock, nanoseconds_t duration)
 Sleep specified amount of time. More...
 
std::tm nanoseconds_2_tm (nanoseconds_t timestamp)
 Convert timestamp in nanoseconds format to broken-down time. More...
 
nanoseconds_t tm_2_nanoseconds (std::tm tm)
 Convert timestamp from broken-down time to nanoseconds format. More...
 
bool ns_equal_delta (nanoseconds_t a, nanoseconds_t b, nanoseconds_t delta)
 Compares a and b if they close enough. More...
 
bool uuid_generare (char *buf, size_t buf_sz)
 Generate UUID string into given buffer. More...
 

Variables

const nanoseconds_t Nanosecond = 1
 One nanosecond represented in nanoseconds. More...
 
const nanoseconds_t Microsecond = 1000 * Nanosecond
 One microsecond represented in nanoseconds. More...
 
const nanoseconds_t Millisecond = 1000 * Microsecond
 One millisecond represented in nanoseconds. More...
 
const nanoseconds_t Second = 1000 * Millisecond
 One second represented in nanoseconds. More...
 
const nanoseconds_t Minute = 60 * Second
 One minute represented in nanoseconds. More...
 
const nanoseconds_t Hour = 60 * Minute
 One hour represented in nanoseconds. More...
 
const nanoseconds_t Day = 24 * Hour
 One day represented in nanoseconds. More...
 

Detailed Description

General-purpose building blocks and platform abstraction layer.

Typedef Documentation

◆ BufferPtr

Buffer smart pointer.

Definition at line 29 of file buffer.h.

◆ hashsum_t

typedef size_t roc::core::hashsum_t

Hash type.

Definition at line 21 of file hashsum.h.

◆ LogHandler

typedef void(* roc::core::LogHandler) (const LogMessage &message, void **args)

Log handler.

Definition at line 99 of file log.h.

◆ nanoseconds_t

typedef int64_t roc::core::nanoseconds_t

Nanoseconds.

Definition at line 58 of file time.h.

◆ seqlock_version_t

typedef uint32_t roc::core::seqlock_version_t

Type for holding seqlock value version. Version is changed each value update. May wrap.

Definition at line 23 of file seqlock_impl.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Default memory pool guards.

Definition at line 37 of file slab_pool.h.

◆ anonymous enum

anonymous enum
Enumerator
UuidLen 

Number of characters in UUID string.

Definition at line 20 of file uuid.h.

◆ anonymous enum

anonymous enum

Default heap arena guards. Leak guard is disabled by default, because in C API leaks may be caused by user (e.g. if context wasn't closed before program exit). We don't want to turn bugs in user code into panics, only bugs in our own code should cause panics.

Definition at line 37 of file heap_arena.h.

◆ clock_t

Clock identifier.

Enumerator
ClockMonotonic 

Virtual monotonic clock.

Remarks
Starts at unspecified point of time.

When platform supports it, uses the clock source that grows monotonically. It never jumps backwards and is not affected by system clock change.

This clock is still subject to clock rate adjustments applied by NTP daemon. When it performs synchronization, it may slightly speed up or slow down both unix and monotonic clocks for a while.

Usually this clock is reset after reboot. Usually this clock does not count time spent in suspended state.

Note
If platform does not have monotonic clock source, unix clock is used. Actual precision is platform-dependent.
ClockUnix 

Real-time Unix-time UTC clock.

Remarks
Starts at 1 Jan 1970 00:00:00 UTC.

May instantly jump forwards or backwards when system administrator sets time. May speed up or slow down when NTP daemon adjusts clock rate. May experience discontinuities when NTP daemon inserts leap seconds.

Note
Available on all platforms. Actual precision is platform-dependent.

Definition at line 21 of file time.h.

◆ Color [1/2]

Color ID.

Definition at line 21 of file console.h.

◆ Color [2/2]

Color ID.

Definition at line 21 of file console.h.

◆ ColorsMode

Colors mode.

Enumerator
ColorsAuto 

Automatically use colored logs if colors are supported.

ColorsEnabled 

Use colored logs.

ColorsDisabled 

Do not use colored logs.

Definition at line 55 of file log.h.

◆ HeapArenaGuard

Heap arena guards.

Enumerator
HeapArena_LeakGuard 

Panic if leaks detected in arena destructor.

HeapArena_OverflowGuard 

Panic if detected buffer overflow when deallocating chunk.

HeapArena_OwnershipGuard 

Panic if detected ownership mismatch when deallocating chunk.

Definition at line 24 of file heap_arena.h.

◆ LocationMode

Location mode.

Enumerator
LocationEnabled 

Show location.

LocationDisabled 

Do not show location.

Definition at line 62 of file log.h.

◆ SlabPoolGuard

Memory pool guards.

Enumerator
SlabPool_LeakGuard 

Panic if leaks detected in pool destructor.

SlabPool_OverflowGuard 

Panic if detected buffer overflow when deallocating object.

SlabPool_OwnershipGuard 

Panic if detected ownership mismatch when deallocating object.

Definition at line 27 of file slab_pool.h.

Function Documentation

◆ console_println() [1/2]

void roc::core::console_println ( Color  color,
const char *  format,
  ... 
)

Print line (with color).

◆ console_println() [2/2]

void roc::core::console_println ( const char *  format,
  ... 
)

Print line.

◆ console_supports_colors()

bool roc::core::console_supports_colors ( )

Check if colors can be used.

◆ cpu_relax()

void roc::core::cpu_relax ( )
inline

CPU pause instruction.

Remarks
Doesn't include any memory barriers, so the caller is responsible to insert them into the loop. Allowed to expand to nothing.

Definition at line 46 of file cpu_instructions.h.

◆ demangle_symbol()

const char* roc::core::demangle_symbol ( const char *  mangled,
char *&  demangled_buf,
size_t &  demangled_size 
)

Demangle symbol name.

Note
This function is NOT signal-safe. It CAN use heap and stdio.
Remarks
demangled_buf and demangled_size specify the buffer for demangled name. When necessary, this function malloc()s or realloc()s demangled_buf and updates demangled_size accordingly. The buffer may be NULL. The buffer may be resused across several calls. The user should manually free() the buffer when it's not needed anymore.
Returns
demangled symbol or NULL if the symbol can't be demangled.

◆ die_fast()

void roc::core::die_fast ( int  code)

Terminate program.

Remarks
Terminates immediately without calling destructors and exit handlers.

◆ die_gracefully()

void roc::core::die_gracefully ( const char *  message,
bool  full_backtrace 
)

Terminate program with error message and backtrace.

Remarks
Prints error message, backtraces, and terminates program with error.

◆ fast_random()

uint32_t roc::core::fast_random ( )

Get a random integer from a non cryptographically secure, but fast PRNG. Thread-safe.

Returns
random value between 0 and UINT32_MAX.

◆ fast_random_gaussian()

double roc::core::fast_random_gaussian ( )

Get a random double from a non cryptographically secure, but fast PRNG. Thread-safe.

Returns
normally distibure random value with 1 variance.

◆ fast_random_range()

uint32_t roc::core::fast_random_range ( uint32_t  from,
uint32_t  to 
)

Get a random integer from a non cryptographically secure, but fast PRNG. Thread-safe.

Returns
random value in inclusive range [from; to].

◆ hashsum_add()

void roc::core::hashsum_add ( hashsum_t hash,
const void *  data,
size_t  size 
)

Incrementally compute hash of memory chunks. On first invocation, hash should be zero.

◆ hashsum_int() [1/7]

hashsum_t roc::core::hashsum_int ( int16_t  )

Compute hash of 16-bit integer.

◆ hashsum_int() [2/7]

hashsum_t roc::core::hashsum_int ( int32_t  )

Compute hash of 32-bit integer.

◆ hashsum_int() [3/7]

hashsum_t roc::core::hashsum_int ( int64_t  )

Compute hash of 64-bit integer.

◆ hashsum_int() [4/7]

template<class T >
hashsum_t roc::core::hashsum_int ( t)

Compute hash of an integer. This fallback is needed for the cases when the overloads above do not cover all builtin types. E.g. if none of the overloads above covers unsigned long or unsigned long long.

Definition at line 45 of file hashsum.h.

◆ hashsum_int() [5/7]

hashsum_t roc::core::hashsum_int ( uint16_t  )

Compute hash of 16-bit integer.

◆ hashsum_int() [6/7]

hashsum_t roc::core::hashsum_int ( uint32_t  )

Compute hash of 32-bit integer.

◆ hashsum_int() [7/7]

hashsum_t roc::core::hashsum_int ( uint64_t  )

Compute hash of 64-bit integer.

◆ hashsum_mem()

hashsum_t roc::core::hashsum_mem ( const void *  data,
size_t  size 
)

Compute hash of byte range.

◆ hashsum_str()

hashsum_t roc::core::hashsum_str ( const char *  str)

Compute hash of zero-terminated string.

◆ hton16s()

int16_t roc::core::hton16s ( int16_t  v)
inline

Host to network byte order (signed 16-bit).

Definition at line 59 of file endian.h.

◆ hton16u()

uint16_t roc::core::hton16u ( uint16_t  v)
inline

Host to network byte order (unsigned 16-bit).

Definition at line 54 of file endian.h.

◆ hton32s()

int32_t roc::core::hton32s ( int32_t  v)
inline

Host to network byte order (signed 32-bit).

Definition at line 69 of file endian.h.

◆ hton32u()

uint32_t roc::core::hton32u ( uint32_t  v)
inline

Host to network byte order (unsigned 32-bit).

Definition at line 64 of file endian.h.

◆ hton64s()

int64_t roc::core::hton64s ( int64_t  v)
inline

Host to network byte order (signed 64-bit).

Definition at line 79 of file endian.h.

◆ hton64u()

uint64_t roc::core::hton64u ( uint64_t  v)
inline

Host to network byte order (unsigned 64-bit).

Definition at line 74 of file endian.h.

◆ nanoseconds_2_tm()

std::tm roc::core::nanoseconds_2_tm ( nanoseconds_t  timestamp)

Convert timestamp in nanoseconds format to broken-down time.

Note
std::tm has precision of one second.

◆ ns_equal_delta()

bool roc::core::ns_equal_delta ( nanoseconds_t  a,
nanoseconds_t  b,
nanoseconds_t  delta 
)

Compares a and b if they close enough.

◆ ntoh16s()

int16_t roc::core::ntoh16s ( int16_t  v)
inline

Network to host byte order (signed 16-bit).

Definition at line 29 of file endian.h.

◆ ntoh16u()

uint16_t roc::core::ntoh16u ( uint16_t  v)
inline

Network to host byte order (unsigned 16-bit).

Definition at line 24 of file endian.h.

◆ ntoh32s()

int32_t roc::core::ntoh32s ( int32_t  v)
inline

Network to host byte order (signed 32-bit).

Definition at line 39 of file endian.h.

◆ ntoh32u()

uint32_t roc::core::ntoh32u ( uint32_t  v)
inline

Network to host byte order (unsigned 32-bit).

Definition at line 34 of file endian.h.

◆ ntoh64s()

int64_t roc::core::ntoh64s ( int64_t  v)
inline

Network to host byte order (signed 64-bit).

Definition at line 49 of file endian.h.

◆ ntoh64u()

uint64_t roc::core::ntoh64u ( uint64_t  v)
inline

Network to host byte order (unsigned 64-bit).

Definition at line 44 of file endian.h.

◆ operator!=()

template<class T1 , class T2 >
bool roc::core::operator!= ( const SharedPtr< T1 > &  a,
const SharedPtr< T2 > &  b 
)
inline

Equality check.

Definition at line 142 of file shared_ptr.h.

◆ operator==()

template<class T1 , class T2 >
bool roc::core::operator== ( const SharedPtr< T1 > &  a,
const SharedPtr< T2 > &  b 
)
inline

Equality check.

Definition at line 136 of file shared_ptr.h.

◆ panic()

void roc::core::panic ( const char *  module,
const char *  file,
int  line,
const char *  format,
  ... 
)

Print error message and terminate program gracefully.

◆ parse_duration()

ROC_ATTR_NODISCARD bool roc::core::parse_duration ( const char *  string,
nanoseconds_t result 
)

Parse duration from string.

Remarks
The input string should be in one of the following forms:
  • "<number>ns"
  • "<number>us"
  • "<number>ms"
  • "<number>s"
  • "<number>m"
  • "<number>h"
Returns
false if string can't be parsed.

◆ parse_size()

ROC_ATTR_NODISCARD bool roc::core::parse_size ( const char *  string,
size_t &  result 
)

Parse size from string.

Remarks
The input string should be in one of the following forms:
  • "<number>"
  • "<number>K"
  • "<number>M"
  • "<number>G"
Returns
false if string can't be parsed.

◆ print_backtrace_full()

void roc::core::print_backtrace_full ( )

Print backtrace to stderr.

Note
This function is NOT signal-safe It CAN use heap and stdio.

◆ print_backtrace_safe()

void roc::core::print_backtrace_safe ( )

Print backtrace to stderr (emergency mode).

Note
This function IS signal-safe. It can NOT use heap and stdio.

◆ print_memory() [1/10]

void roc::core::print_memory ( const double *  data,
size_t  size 
)

Print memory.

◆ print_memory() [2/10]

void roc::core::print_memory ( const float *  data,
size_t  size 
)

Print memory.

◆ print_memory() [3/10]

void roc::core::print_memory ( const int16_t *  data,
size_t  size 
)

Print memory.

◆ print_memory() [4/10]

void roc::core::print_memory ( const int32_t *  data,
size_t  size 
)

Print memory.

◆ print_memory() [5/10]

void roc::core::print_memory ( const int64_t *  data,
size_t  size 
)

Print memory.

◆ print_memory() [6/10]

void roc::core::print_memory ( const int8_t *  data,
size_t  size 
)

Print memory.

◆ print_memory() [7/10]

void roc::core::print_memory ( const uint16_t *  data,
size_t  size 
)

Print memory.

◆ print_memory() [8/10]

void roc::core::print_memory ( const uint32_t *  data,
size_t  size 
)

Print memory.

◆ print_memory() [9/10]

void roc::core::print_memory ( const uint64_t *  data,
size_t  size 
)

Print memory.

◆ print_memory() [10/10]

void roc::core::print_memory ( const uint8_t *  data,
size_t  size 
)

Print memory.

◆ print_memory_slice() [1/10]

void roc::core::print_memory_slice ( const double *  inner,
size_t  inner_size,
const double *  outer,
size_t  outer_size 
)

Print memory slice.

◆ print_memory_slice() [2/10]

void roc::core::print_memory_slice ( const float *  inner,
size_t  inner_size,
const float *  outer,
size_t  outer_size 
)

Print memory slice.

◆ print_memory_slice() [3/10]

void roc::core::print_memory_slice ( const int16_t *  inner,
size_t  inner_size,
const int16_t *  outer,
size_t  outer_size 
)

Print memory slice.

◆ print_memory_slice() [4/10]

void roc::core::print_memory_slice ( const int32_t *  inner,
size_t  inner_size,
const int32_t *  outer,
size_t  outer_size 
)

Print memory slice.

◆ print_memory_slice() [5/10]

void roc::core::print_memory_slice ( const int64_t *  inner,
size_t  inner_size,
const int64_t *  outer,
size_t  outer_size 
)

Print memory slice.

◆ print_memory_slice() [6/10]

void roc::core::print_memory_slice ( const int8_t *  inner,
size_t  inner_size,
const int8_t *  outer,
size_t  outer_size 
)

Print memory slice.

◆ print_memory_slice() [7/10]

void roc::core::print_memory_slice ( const uint16_t *  inner,
size_t  inner_size,
const uint16_t *  outer,
size_t  outer_size 
)

Print memory slice.

◆ print_memory_slice() [8/10]

void roc::core::print_memory_slice ( const uint32_t *  inner,
size_t  inner_size,
const uint32_t *  outer,
size_t  outer_size 
)

Print memory slice.

◆ print_memory_slice() [9/10]

void roc::core::print_memory_slice ( const uint64_t *  inner,
size_t  inner_size,
const uint64_t *  outer,
size_t  outer_size 
)

Print memory slice.

◆ print_memory_slice() [10/10]

void roc::core::print_memory_slice ( const uint8_t *  inner,
size_t  inner_size,
const uint8_t *  outer,
size_t  outer_size 
)

Print memory slice.

◆ seqlock_version_is_valid()

bool roc::core::seqlock_version_is_valid ( seqlock_version_t  ver)
inline

Check if this is a valid seqlock version. Returns false if seqlock version corresponds to intermediate state that should never be seen by seqlock user.

Definition at line 28 of file seqlock_impl.h.

◆ sleep_for()

void roc::core::sleep_for ( clock_t  clock,
nanoseconds_t  duration 
)

Sleep specified amount of time.

Remarks
duration specifies number of nanoseconds to sleep.

◆ sleep_until()

void roc::core::sleep_until ( clock_t  clock,
nanoseconds_t  timestamp 
)

Sleep until the specified absolute time point has been reached.

Remarks
timestamp specifies absolute time point in nanoseconds.

◆ timestamp()

nanoseconds_t roc::core::timestamp ( clock_t  clock)

Get current timestamp in nanoseconds.

◆ tm_2_nanoseconds()

nanoseconds_t roc::core::tm_2_nanoseconds ( std::tm  tm)

Convert timestamp from broken-down time to nanoseconds format.

Note
std::tm has precision of one second.

◆ uuid_generare()

bool roc::core::uuid_generare ( char *  buf,
size_t  buf_sz 
)

Generate UUID string into given buffer.

Note
Generated string has UuidLen characters + null terminator. Panics if buf is null or buf_sz is less than UuidLen + 1.

Variable Documentation

◆ Day

const nanoseconds_t roc::core::Day = 24 * Hour

One day represented in nanoseconds.

Definition at line 79 of file time.h.

◆ Hour

const nanoseconds_t roc::core::Hour = 60 * Minute

One hour represented in nanoseconds.

Definition at line 76 of file time.h.

◆ Microsecond

const nanoseconds_t roc::core::Microsecond = 1000 * Nanosecond

One microsecond represented in nanoseconds.

Definition at line 64 of file time.h.

◆ Millisecond

const nanoseconds_t roc::core::Millisecond = 1000 * Microsecond

One millisecond represented in nanoseconds.

Definition at line 67 of file time.h.

◆ Minute

const nanoseconds_t roc::core::Minute = 60 * Second

One minute represented in nanoseconds.

Definition at line 73 of file time.h.

◆ Nanosecond

const nanoseconds_t roc::core::Nanosecond = 1

One nanosecond represented in nanoseconds.

Definition at line 61 of file time.h.

◆ Second

const nanoseconds_t roc::core::Second = 1000 * Millisecond

One second represented in nanoseconds.

Definition at line 70 of file time.h.