Convert-Binary-C
view release on metacpan or search on metacpan
tests/include/pdclib/platform/example/include/threads.h view on Meta::CPAN
/* Unblock threads waiting on given condition.
Returns thrd_success if successful, thrd_error if the request could not
be honored.
*/
_PDCLIB_PUBLIC int cnd_broadcast( cnd_t * cond );
/* Destroy condition variable.
No threads may be waiting on a condition when it is destroyed.
*/
_PDCLIB_PUBLIC void cnd_destroy( cnd_t * cond );
/* Initialize condition variable.
Returns thrd_success if successful, thrd_nomem if out of memory, and
thrd_error if the request could not be honored.
Initializes the variable in a way that a thread calling cnd_wait() on it
would block.
*/
_PDCLIB_PUBLIC int cnd_init( cnd_t * cond );
/* Unblock one thread waiting on the condition variable.
Returns thrd_success if successful, thrd_error if the request could not
be honored.
*/
_PDCLIB_PUBLIC int cnd_signal( cnd_t * cond );
/* TODO: Documentation.
Returns thrd_success if successful, thrd_timedout if the specified time
is reached without acquiring the resource, or thrd_error if the request
could not be honored.
*/
_PDCLIB_PUBLIC int cnd_timedwait( cnd_t * _PDCLIB_restrict cond, mtx_t * _PDCLIB_restrict mtx, const struct timespec * _PDCLIB_restrict ts );
/* TODO: Documentation.
Returns thrd_success if successful, thrd_error if the request could not
be honored.
*/
int cnd_wait( cnd_t * cond, mtx_t * mtx );
/* Mutex functions */
/* Destroy mutex variable.
No threads may be waiting on a mutex when it is destroyed.
*/
_PDCLIB_PUBLIC void mtx_destroy( mtx_t * mtx );
/* Initialize mutex variable.
Returns thrd_success if successful, thrd_error if the request could not
be honored.
Type must have one of the following values:
mtx_plain -- non-recursive mutex
mtx_timed -- non-recursive mutex supporting timeout
mtx_plain | mtx_recursive -- recursive mutex
mtx_timed | mtx_recursive -- recursive mutex supporting timeout
*/
_PDCLIB_PUBLIC int mtx_init( mtx_t * mtx, int type );
/* Try to lock the given mutex (blocking).
Returns thrd_success if successful, thrd_error if the request could not
be honored.
If the given mutex is non-recursive, it must not be already locked by
the calling thread.
*/
_PDCLIB_PUBLIC int mtx_lock( mtx_t * mtx );
/* TODO: Documentation.
Returns thrd_success if successful, thrd_timedout if the specified time
is reached without acquiring the resource, or thrd_error if the request
could not be honored.
*/
_PDCLIB_PUBLIC int mtx_timedlock( mtx_t * _PDCLIB_restrict mtx, const struct timespec * _PDCLIB_restrict ts );
/* Try to lock the given mutex (non-blocking).
Returns thrd_success if successful, thrd_busy if the resource is already
locked, or thrd_error if the request could not be honored.
*/
_PDCLIB_PUBLIC int mtx_trylock( mtx_t * mtx );
/* Unlock the given mutex.
Returns thrd_success if successful, thrd_error if the request could not
be honored.
The given mutex must be locked by the calling thread.
*/
_PDCLIB_PUBLIC int mtx_unlock( mtx_t * mtx );
/* Thread functions */
/* Create a new thread.
Returns thrd_success if successful, thrd_nomem if out of memory, and
thrd_error if the request could not be honored.
Create a new thread executing func( arg ), and sets thr to identify
the created thread. (Identifiers may be reused afer a thread exited
and was either detached or joined.)
*/
_PDCLIB_PUBLIC int thrd_create( thrd_t * thr, thrd_start_t func, void * arg );
/* Identify the calling thread.
Returns the identifier of the calling thread.
*/
_PDCLIB_PUBLIC thrd_t thrd_current( void );
/* Notify the OS to destroy all resources of a given thread once it
terminates.
Returns thrd_success if successful, thrd_error if the request could not
be honored.
The given thread must not been previously detached or joined.
*/
_PDCLIB_PUBLIC int thrd_detach( thrd_t thr );
/* Compare two thread identifiers for equality.
Returns nonzero if both parameters identify the same thread, zero
otherwise.
*/
_PDCLIB_PUBLIC int thrd_equal( thrd_t thr0, thrd_t thr1 );
/* Terminate calling thread, set result code to res.
When the last thread of a program terminates the program shall terminate
normally as if by exit( EXIT_SUCCESS ).
FIXME: The result code setting is NOT implemented correctly at this point.
The value is indeterminate.
*/
_PDCLIB_PUBLIC _PDCLIB_Noreturn void thrd_exit( int res ) _PDCLIB_NORETURN;
/* Join the given thread with the calling thread.
Returns thrd_success if successful, thrd_error if the request could not
be honored.
Function blocks until the given thread terminates. If res is not NULL,
the given thread's result code will be stored at that address.
*/
_PDCLIB_PUBLIC int thrd_join( thrd_t thr, int * res );
/* Suspend the calling thread for the given duration or until a signal not
being ignored is received.
Returns zero if the requested time has elapsed, -1 if interrupted by a
signal, negative if the request failed.
If remaining is not NULL, and the sleeping thread received a signal that
is not being ignored, the remaining time (duration minus actually elapsed
time) shall be stored at that address.
*/
_PDCLIB_PUBLIC int thrd_sleep( const struct timespec * duration, struct timespec * remaining );
/* Permit other threads to run. */
( run in 0.834 second using v1.01-cache-2.11-cpan-39bf76dae61 )