C++ Library, mos@ua
0.9
cpplib-mos
|
POSIX threads library wrapper module. More...
Files | |
file | thread.h |
POSIX threads library wrapper module. | |
Thread handling | |
int | thread_equal (pthread_t t1, pthread_t t2) |
pthread_equal wrapper function. More... | |
void | thread_create (pthread_t *t, pthread_attr_t *attr, void *(*thread_main)(void *), void *arg) |
pthread_create wrapper function. More... | |
pthread_t | thread_self () |
pthread_self wrapper function. More... | |
void | thread_sched_yield (void) |
sched_yield wrapper function. More... | |
void | thread_exit (void *retval) |
pthread_exit wrapper function. More... | |
void | thread_detach (pthread_t thread) |
pthread_detach wrapper function. More... | |
void | thread_join (pthread_t t, void **result) |
pthread_join wrapper function. More... | |
Mutexes | |
Variable type: Initialization of mutexes can be static or dynamic. In static initialization the following initialization macros are suggested:
Dynamic initialization is done by mutex_init() and mutex_destroy(). | |
void | mutex_init (pthread_mutex_t *pmtx, pthread_mutexattr_t *attr) |
pthread_mutex_init wrapper function. More... | |
void | mutex_destroy (pthread_mutex_t *pmtx) |
pthread_mutex_destroy wrapper function. More... | |
void | mutex_lock (pthread_mutex_t *pmtx) |
pthread_mutex_lock wrapper function. More... | |
int | mutex_trylock (pthread_mutex_t *pmtx) |
pthread_mutex_trylock wrapper function. More... | |
void | mutex_unlock (pthread_mutex_t *pmtx) |
pthread_mutex_unlock wrapper function. More... | |
Condition variables | |
Initialization of condition variables can be static or dynamic. In static initialization the following initialization macros should be used:
Dynamic initialization is done by cond_init() and cond_destroy(). | |
void | cond_init (pthread_cond_t *pcvar, pthread_condattr_t *attr) |
pthread_cond_init wrapper function. More... | |
void | cond_destroy (pthread_cond_t *pcvar) |
pthread_cond_destroy wrapper function. More... | |
void | cond_wait (pthread_cond_t *pcvar, pthread_mutex_t *pmtx) |
pthread_cond_wait wrapper function. More... | |
int | cond_timedwait (pthread_cond_t *pcvar, pthread_mutex_t *pmtx, const struct timespec *abstime) |
pthread_cond_timedwait wrapper function. More... | |
void | cond_signal (pthread_cond_t *pcvar) |
pthread_cond_signal wrapper function. More... | |
void | cond_broadcast (pthread_cond_t *pcvar) |
pthread_cond_broadcast wrapper function. More... | |
One-time initialization | |
POSIX thread library support a mechanism that ensures a one-time execution of a function. It does it through
| |
void | thread_once (pthread_once_t *once_control, void(*init_routine)(void)) |
pthread_once wrapper function. More... | |
Thread-specific data | |
Thread-specific data allows the definition of variable whose scope is limited to each thread. In practice, we will have a common variable, with a common access, but with different values for each thread. | |
void | thread_key_create (pthread_key_t *key, void(*destr_function)(void *)) |
pthread_key_create wrapper function. More... | |
void | thread_key_delete (pthread_key_t key) |
pthread_key_delete wrapper function. More... | |
void | thread_setspecific (pthread_key_t key, void *pointer) |
pthread_setspecific wrapper function. More... | |
void * | thread_getspecific (pthread_key_t key) |
pthread_getspecific wrapper function. More... | |
Mutex attributes | |
void | mutexattr_init (pthread_mutexattr_t *attr) |
pthread_mutexattr_init wrapper function. More... | |
void | mutexattr_destroy (pthread_mutexattr_t *attr) |
pthread_mutexattr_destroy wrapper function. More... | |
void | mutexattr_settype (pthread_mutexattr_t *attr, int type) |
pthread_mutexattr_settype wrapper function. More... | |
void | mutexattr_gettype (const pthread_mutexattr_t *attr, int *kind) |
pthread_mutexattr_gettype wrapper function. More... | |
Condition variables attributes | |
void | condattr_init (pthread_condattr_t *attr) |
pthread_condattr_init wrapper function. More... | |
void | condattr_destroy (pthread_condattr_t *attr) |
pthread_condattr_destroy wrapper function. More... | |
Thread attributes | |
void | thread_attr_init (pthread_attr_t *attr) |
pthread_attr_init wrapper function. More... | |
void | thread_attr_destroy (pthread_attr_t *attr) |
pthread_attr_destroy wrapper function. More... | |
void | thread_attr_setdetachstate (pthread_attr_t *attr, int detachstate) |
pthread_attr_setdetachstate wrapper function. More... | |
void | thread_attr_getdetachstate (const pthread_attr_t *attr, int *pdetachstate) |
pthread_attr_getdetachstate wrapper function. More... | |
Cancellation | |
void | thread_cancel (pthread_t thread) |
pthread_cancel wrapper function. More... | |
void | thread_setcancelstate (int state, int *oldstate) |
pthread_setcancelstate wrapper function. More... | |
void | thread_setcanceltype (int type, int *oldtype) |
pthread_setcanceltype wrapper function. More... | |
void | thread_testcancel (void) |
pthread_testcancel wrapper function. More... | |
POSIX threads library wrapper module.
This module removes defensive programming approach of native POSIX threads library.
All implemented functions, have exactly the same arguments and/or result of the original function, with the exception of returning an error indication.
Errors are handled by the implementation of two policies:
stderr
(with the identification of the errno error, and the precise location the call), generates a segmentation fault (enabling a stack trace within a debugger like gdb
), and exits program execution;int
exception with the (errno) status error returned by the original function.int thread_equal | ( | pthread_t | t1, |
pthread_t | t2 | ||
) |
pthread_equal
wrapper function.
Documentation in
man 3 pthread_equal
void thread_create | ( | pthread_t * | t, |
pthread_attr_t * | attr, | ||
void *(*)(void *) | thread_main, | ||
void * | arg | ||
) |
pthread_create
wrapper function.
t != NULL
thread_main != NULL
Documentation in
man 3 pthread_create
pthread_t thread_self | ( | ) |
pthread_self
wrapper function.
Documentation in
man 3 pthread_self
void thread_sched_yield | ( | void | ) |
sched_yield
wrapper function.
Documentation in
man 3 sched_yield
void thread_exit | ( | void * | retval | ) |
pthread_exit
wrapper function.
Documentation in
man 3 pthread_exit
void thread_detach | ( | pthread_t | thread | ) |
pthread_detach
wrapper function.
Documentation in
man 3 pthread_detach
void thread_join | ( | pthread_t | t, |
void ** | result | ||
) |
pthread_join
wrapper function.
Documentation in
man 3 pthread_join
void mutex_init | ( | pthread_mutex_t * | pmtx, |
pthread_mutexattr_t * | attr | ||
) |
pthread_mutex_init
wrapper function.
pmtx != NULL
Documentation in
man 3 pthread_mutex_init
void mutex_destroy | ( | pthread_mutex_t * | pmtx | ) |
pthread_mutex_destroy
wrapper function.
pmtx != NULL
Documentation in
man 3 pthread_mutex_destroy
void mutex_lock | ( | pthread_mutex_t * | pmtx | ) |
pthread_mutex_lock
wrapper function.
pmtx != NULL
Documentation in
man 3 pthread_mutex_lock
int mutex_trylock | ( | pthread_mutex_t * | pmtx | ) |
pthread_mutex_trylock
wrapper function.
pmtx != NULL
Documentation in
man 3 pthread_mutex_trylock
!=0
) if lock succeeds, false (0
) otherwise void mutex_unlock | ( | pthread_mutex_t * | pmtx | ) |
pthread_mutex_unlock
wrapper function.
pmtx != NULL
Documentation in
man 3 pthread_mutex_unlock
void cond_init | ( | pthread_cond_t * | pcvar, |
pthread_condattr_t * | attr | ||
) |
pthread_cond_init
wrapper function.
pcvar != NULL
Documentation in
man 3 pthread_cond_init
void cond_destroy | ( | pthread_cond_t * | pcvar | ) |
pthread_cond_destroy
wrapper function.
pcvar != NULL
Documentation in
man 3 pthread_cond_destroy
void cond_wait | ( | pthread_cond_t * | pcvar, |
pthread_mutex_t * | pmtx | ||
) |
pthread_cond_wait
wrapper function.
pcvar != NULL
pmtx != NULL
Documentation in
man 3 pthread_cond_wait
int cond_timedwait | ( | pthread_cond_t * | pcvar, |
pthread_mutex_t * | pmtx, | ||
const struct timespec * | abstime | ||
) |
pthread_cond_timedwait
wrapper function.
pcvar != NULL
pmtx != NULL
abstime != NULL
!=0
) if condition variable was signaled, false (0
) it time out has expired.Documentation in
man 3 pthread_cond_timedwait
void cond_signal | ( | pthread_cond_t * | pcvar | ) |
pthread_cond_signal
wrapper function.
pcvar != NULL
Documentation in
man 3 pthread_cond_signal
void cond_broadcast | ( | pthread_cond_t * | pcvar | ) |
pthread_cond_broadcast
wrapper function.
pcvar != NULL
Documentation in
man 3 pthread_cond_broadcast
void thread_once | ( | pthread_once_t * | once_control, |
void(*)(void) | init_routine | ||
) |
pthread_once
wrapper function.
once_control != NULL
init_routine != NULL
Documentation in
man 3 pthread_once
void thread_key_create | ( | pthread_key_t * | key, |
void(*)(void *) | destr_function | ||
) |
pthread_key_create
wrapper function.
This function should be executed once for each key (use thread_once()).
key != NULL
Documentation in
man 3 pthread_key_create
void thread_key_delete | ( | pthread_key_t | key | ) |
pthread_key_delete
wrapper function.
This function should be executed once for each key (use thread_once()).
key != NULL
Documentation in
man 3 pthread_key_delete
void thread_setspecific | ( | pthread_key_t | key, |
void * | pointer | ||
) |
pthread_setspecific
wrapper function.
pointer != NULL
Documentation in
man 3 pthread_setspecific
void* thread_getspecific | ( | pthread_key_t | key | ) |
pthread_getspecific
wrapper function.
key != NULL
Documentation in
man 3 pthread_getspecific
void mutexattr_init | ( | pthread_mutexattr_t * | attr | ) |
pthread_mutexattr_init
wrapper function.
attr != NULL
Documentation in
man 3 pthread_mutexattr_init
void mutexattr_destroy | ( | pthread_mutexattr_t * | attr | ) |
pthread_mutexattr_destroy
wrapper function.
attr != NULL
Documentation in
man 3 pthread_mutexattr_destroy
void mutexattr_settype | ( | pthread_mutexattr_t * | attr, |
int | type | ||
) |
pthread_mutexattr_settype
wrapper function.
attr != NULL
Documentation in
man 3 pthread_mutexattr_settype
void mutexattr_gettype | ( | const pthread_mutexattr_t * | attr, |
int * | kind | ||
) |
pthread_mutexattr_gettype
wrapper function.
attr != NULL
kind != NULL
Documentation in
man 3 pthread_mutexattr_gettype
void condattr_init | ( | pthread_condattr_t * | attr | ) |
pthread_condattr_init
wrapper function.
attr != NULL
Documentation in
man 3 pthread_condattr_init
void condattr_destroy | ( | pthread_condattr_t * | attr | ) |
pthread_condattr_destroy
wrapper function.
attr != NULL
Documentation in
man 3 pthread_condattr_destroy
void thread_attr_init | ( | pthread_attr_t * | attr | ) |
pthread_attr_init
wrapper function.
attr != NULL
Documentation in
man 3 pthread_attr_init
void thread_attr_destroy | ( | pthread_attr_t * | attr | ) |
pthread_attr_destroy
wrapper function.
attr != NULL
Documentation in
man 3 pthread_attr_destroy
void thread_attr_setdetachstate | ( | pthread_attr_t * | attr, |
int | detachstate | ||
) |
pthread_attr_setdetachstate
wrapper function.
attr != NULL
detachstate == PTHREAD_CREATE_DETACHED || detachstate == PTHREAD_CREATE_JOINABLE
Documentation in
man 3 pthread_attr_setdetachstate
void thread_attr_getdetachstate | ( | const pthread_attr_t * | attr, |
int * | pdetachstate | ||
) |
pthread_attr_getdetachstate
wrapper function.
attr != NULL
pdetachstate != NULL
Documentation in
man 3 pthread_attr_getdetachstate
void thread_cancel | ( | pthread_t | thread | ) |
pthread_cancel
wrapper function.
Documentation in
man 3 pthread_cancel
void thread_setcancelstate | ( | int | state, |
int * | oldstate | ||
) |
pthread_setcancelstate
wrapper function.
state == PTHREAD_CANCEL_ENABLE || state == PTHREAD_CANCEL_DISABLE
oldstate != NULL
Documentation in
man 3 pthread_setcancelstate
void thread_setcanceltype | ( | int | type, |
int * | oldtype | ||
) |
pthread_setcanceltype
wrapper function.
type == PTHREAD_CANCEL_DEFERRED || type == PTHREAD_CANCEL_ASYNCHRONOUS
oldtype != NULL
Documentation in
man 3 pthread_setcanceltype
void thread_testcancel | ( | void | ) |
pthread_testcancel
wrapper function.
Documentation in
man 3 pthread_testcancel