23 #ifndef REGIFY_UTIL_THREAD_H
24 #define REGIFY_UTIL_THREAD_H
27 #define RU_THREAD_LOCAL __declspec(thread)
31 #define RU_THREAD_LOCAL thread_local
33 #define RU_THREAD_LOCAL __thread
146 typedef void* (*ruStartFunc) (
void* context);
298 #define ruMutexTryLock(m) ruMutexTryLockLoc(m, __FILE__, __func__, __LINE__)
313 #define ruMutexLock(m) ruMutexLockLoc(m, __FILE__, __func__, __LINE__)
325 #define ruMutexUnlock(m) ruMutexUnlockLoc(m, __FILE__, __func__, __LINE__)
353 #define ruCounterInc(counter, value) ruCounterIncValue(counter, value, NULL)
358 #define ruCounterRead(counter) ruCounterIncValue(counter, 0, NULL)
372 #define ruCountSet(counter, value) ruCountSetValue(counter, value, NULL)
void * ruList
Opaque pointer to list object. See List Collection.
Definition: list.h:103
const void * perm_ptr
A permanent pointer.
Definition: regify-util.h:277
const char * trans_chars
A transient NULL terminated string pointer.
Definition: regify-util.h:186
const char * perm_chars
A permanent NULL terminated string pointer.
Definition: regify-util.h:176
long sec_t
A signed type for expressing seconds.
Definition: regify-util.h:312
char * alloc_chars
An allocated NULL terminated string pointer.
Definition: regify-util.h:199
RUAPI void ruCondSignal(ruCond c)
Unblock a thread waiting for the given condition variable.
void * ruTrace
Definition: thread.h:46
RUAPI ruCond ruCondFree(ruCond c)
Free up given ruCond object.
RUAPI void ruMutexUnlockLoc(ruMutex m, trans_chars filePath, trans_chars func, int32_t line)
Return the aquired mutex lock so other threads can use it.
RUAPI bool ruThreadFinished(ruThread tid, int32_t *code)
Whether thraed has finished and is joinable.
RUAPI ruCount ruCountFree(ruCount counter)
Frees given counter.
RUAPI ruThread ruThreadCreate(ruStartFunc start, alloc_chars name, void *usrCtx)
RUAPI void ruBacktraceInit(perm_chars exePath)
Sets the path to the current executable.
RUAPI bool ruMutexTryLockLoc(ruMutex m, trans_chars filePath, trans_chars func, int32_t line)
Tries to aquire a lock for the given ruMutex without blocking.
RUAPI ruCond ruCondInit(void)
Initialize a new ruCond condition variable.
RUAPI int64_t ruCountSetValue(ruCount counter, int64_t value, int32_t *code)
Sets the counter to given value and returns the previous value.
RUAPI perm_ptr ruTraceAddr(ruTrace rt)
Returns the instruction pointer of the given ruTrace object.
RUAPI perm_ptr ruTraceOffset(ruTrace rt)
Returns the offset from the given function of the given ruTrace object if set.
RUAPI void ruMutexLockLoc(ruMutex m, trans_chars filePath, trans_chars func, int32_t line)
Aquire a lock for the given ruMutex blocking until it is given.
RUAPI ruThreadId ruThreadNativeId(ruThread tid, int32_t *code)
Returns the thread id of the given ruThread.
RUAPI ru_tid ruThreadGetId(void)
void * ruCond
Opaque object abstracting condition signaling.
Definition: thread.h:233
RUAPI uint32_t ruTraceLine(ruTrace rt)
Returns the line number of the given ruTrace object if set.
RUAPI int32_t ruThreadKill(ruThread tid)
RUAPI ruList ruBacktrace(int32_t *code)
Returns a list of ruTrace elements ordered so that the caller is last.
void * ruCount
Definition: thread.h:141
RUAPI void ruCondWaitTil(ruCond c, ruMutex m, int32_t msTimeout)
Wait on the given condition variable or the given timeout.
RUAPI void ruThreadSetName(trans_chars name)
void *(* ruStartFunc)(void *context)
Definition: thread.h:146
void * ruMutex
Opaque object abstracting object locking.
Definition: thread.h:238
RUAPI void ruCondWait(ruCond c, ruMutex m)
Wait on the given condition variable.
RUAPI perm_chars ruTraceFileName(ruTrace rt)
Returns the basename of the filename of the given ruTrace object if set.
RUAPI perm_chars ruThreadGetName(void)
RUAPI bool ruThreadWait(ruThread tid, sec_t tosecs, void **exitVal)
RUAPI void ruTraceLog(trans_chars tag, int32_t skip)
Logs a backtrace.
RUAPI perm_chars ruTraceStr(ruTrace rt)
Returns an optimized string representation of the given ruTrace object.
void * ruThread
Definition: thread.h:136
RUAPI ruMutex ruMutexInit(void)
Initialize a new ruMutex.
pthread_t ruThreadId
Definition: thread.h:130
RUAPI int ruThreadJoin(ruThread tid, void **exitVal)
unsigned long ru_tid
Definition: thread.h:122
RUAPI int64_t ruCounterIncValue(ruCount counter, int64_t value, int32_t *code)
Increments the counter by given value and returns the new value.
RUAPI perm_chars ruTraceFunc(ruTrace rt)
Returns the function name of the given ruTrace object if set.
RUAPI ruThread ruThreadCreateBg(ruStartFunc start, alloc_chars name, void *usrCtx)
Creates a new thread with background priority.
RUAPI perm_chars ruTraceFilePath(ruTrace rt)
Returns the full path to the filename of the given ruTrace object if set.
RUAPI ruMutex ruMutexFree(ruMutex m)
Free up given ruMutex object.
RUAPI ruCount ruCounterNew(int64_t initialCount)
Returns a new thread safe counter initialized to given value.