Worker Context
-
unsigned int lace_worker_count(void)
Get the number of Lace worker threads.
- Returns:
Number of workers started by lace_start()
-
static inline int lace_is_worker(void)
Check whether the calling thread is a Lace worker.
- Returns:
1 if called from a Lace worker thread, 0 otherwise
-
static inline lace_worker *lace_get_worker(void)
Get the calling worker’s private data.
- Returns:
Pointer to the current lace_worker, or NULL if not a worker
-
static inline int lace_worker_id(void)
Get the calling worker’s integer ID.
- Returns:
Worker ID (0-based), or -1 if not called from a Lace worker
-
static inline uint64_t lace_rng(lace_worker *lw)
Thread-local pseudo-random number generator (xoroshiro128**).
Each worker has its own RNG state, so this function is contention-free.
- Parameters:
lw – Pointer to the current worker (from lace_get_worker())
- Returns:
A pseudo-random 64-bit value