3.3. Threads¶
- int thread_get_packet_capture_cpu_count()¶
Get the number of thread to be used by the application for packet capture.
- int thread_get_cpu_count()¶
Get the number of CPUs.
- int thread_get_id()¶
Get current thread id.
3.3.2. Mutex¶
- mutex_t¶
Mutex opaque type.
- MUTEX_INIT¶
Initialize static mutex.
- bool mutex_init(mutex_t *mutex, bool recursive)¶
Initialize a mutex mutex. With recursive, the mutex can be created recursive (ie. can be re-entered by the same thread).
Returns: True on success. Use clear_error() to get details about the error.
- bool mutex_destroy(mutex_t *mutex)¶
Destroy a mutex.
Returns: True on success. Use clear_error() to get details about the error.
- bool mutex_lock(mutex_t *mutex)¶
Lock a mutex.
Returns: True on success. Use clear_error() to get details about the error.
- bool mutex_trylock(mutex_t *mutex)¶
Try to lock a mutex.
Returns: True if successful, False if the lock could not be taken. Use check_error() and clear_error() to get details about the error.
- bool mutex_unlock(mutex_t *mutex)¶
Unlock a mutex.
Returns: True on success. Use clear_error() to get details about the error.
3.3.3. Semaphore¶
- semaphore_t¶
Semaphore opaque type.
- bool semaphore_init(semaphore_t *semaphore, uint32 initial)¶
Initialize a new semaphore with initial value of initial.
Returns: True on success. Use clear_error() to get details about the error.
- bool semaphore_destroy(semaphore_t *semaphore)¶
Destroy a semaphore.
Returns: True on success. Use clear_error() to get details about the error.
- bool semaphore_wait(semaphore_t *semaphore)¶
Wait on a semaphore.
Returns: True on success. Use clear_error() to get details about the error.
- bool semaphore_post(semaphore_t *semaphore)¶
Post on a semaphore.
Returns: True on success. Use clear_error() to get details about the error.
3.3.4. Thread local storage¶
- local_storage_t¶
Thread local storage opaque type.
- bool local_storage_init(local_storage_t *key, void (*destructor)(void *))¶
Initialize thread local storage. The parameter destructor allows to set a cleanup function to call when the storage is destroyed.
Returns: True on success. Use clear_error() to get details about the error.
- bool local_storage_destroy(local_storage_t *key)¶
Destroy a thread local storage.
Returns: True on success. Use clear_error() to get details about the error.
- void *local_storage_get(local_storage_t *key)¶
Get the value of the thread local storage.
Returns: The value associated with the current thread.
- bool local_storage_set(local_storage_t *key, const void *value)¶
Set the value of the thread local storage.
Returns: True on success. Use clear_error() to get details about the error.