Macros | Typedefs | Functions
tinycthread.h File Reference
#include <time.h>
#include <sys/time.h>
#include <pthread.h>
Include dependency graph for tinycthread.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 
#define _POSIX_C_SOURCE   199309L
 
#define _Thread_local
 
#define _TTHREAD_PLATFORM_DEFINED_
 
#define _TTHREAD_POSIX_
 
#define _XOPEN_SOURCE   500
 
#define mtx_plain   1
 
#define mtx_recursive   8
 
#define mtx_timed   2
 
#define mtx_try   4
 
#define thrd_busy   3
 
#define thrd_error   0
 
#define thrd_nomem   4
 
#define thrd_success   1
 
#define thrd_timeout   2
 
#define TIME_UTC   0
 
#define TINYCTHREAD_VERSION   (TINYCTHREAD_VERSION_MAJOR * 100 + TINYCTHREAD_VERSION_MINOR)
 
#define TINYCTHREAD_VERSION_MAJOR   1
 
#define TINYCTHREAD_VERSION_MINOR   1
 
#define TSS_DTOR_ITERATIONS   0
 

Typedefs

typedef pthread_cond_t cnd_t
 
typedef pthread_mutex_t mtx_t
 
typedef int(* thrd_start_t) (void *arg)
 
typedef pthread_t thrd_t
 
typedef void(* tss_dtor_t) (void *val)
 
typedef pthread_key_t tss_t
 

Functions

int cnd_broadcast (cnd_t *cond)
 
void cnd_destroy (cnd_t *cond)
 
int cnd_init (cnd_t *cond)
 
int cnd_signal (cnd_t *cond)
 
int cnd_timedwait (cnd_t *cond, mtx_t *mtx, const struct timespec *ts)
 
int cnd_wait (cnd_t *cond, mtx_t *mtx)
 
void mtx_destroy (mtx_t *mtx)
 
int mtx_init (mtx_t *mtx, int type)
 
int mtx_lock (mtx_t *mtx)
 
int mtx_timedlock (mtx_t *mtx, const struct timespec *ts)
 
int mtx_trylock (mtx_t *mtx)
 
int mtx_unlock (mtx_t *mtx)
 
int thrd_create (thrd_t *thr, thrd_start_t func, void *arg)
 
thrd_t thrd_current (void)
 
int thrd_detach (thrd_t thr)
 
int thrd_equal (thrd_t thr0, thrd_t thr1)
 
void thrd_exit (int res)
 
int thrd_join (thrd_t thr, int *res)
 
int thrd_sleep (const struct timespec *time_point, struct timespec *remaining)
 
void thrd_yield (void)
 
int tss_create (tss_t *key, tss_dtor_t dtor)
 
void tss_delete (tss_t key)
 
voidtss_get (tss_t key)
 
int tss_set (tss_t key, void *val)
 

Macro Definition Documentation

#define _GNU_SOURCE

Definition at line 64 of file tinycthread.h.

#define _POSIX_C_SOURCE   199309L

Definition at line 68 of file tinycthread.h.

#define _Thread_local

Thread local storage keyword. A variable that is declared with the _Thread_local keyword makes the value of the variable local to each thread (known as thread-local storage, or TLS). Example usage:

1 // This variable is local to each thread.
2 _Thread_local int variable;
Note
The _Thread_local keyword is a macro that maps to the corresponding compiler directive (e.g. __declspec(thread)).
This directive is currently not supported on Mac OS X (it will give a compiler error), since compile-time TLS is not supported in the Mac OS X executable format. Also, some older versions of MinGW (before GCC 4.x) do not support this directive.

Definition at line 163 of file tinycthread.h.

#define _TTHREAD_PLATFORM_DEFINED_

Definition at line 57 of file tinycthread.h.

#define _TTHREAD_POSIX_

Definition at line 55 of file tinycthread.h.

#define _XOPEN_SOURCE   500

Definition at line 72 of file tinycthread.h.

#define mtx_plain   1

Definition at line 178 of file tinycthread.h.

#define mtx_recursive   8

Definition at line 181 of file tinycthread.h.

#define mtx_timed   2

Definition at line 179 of file tinycthread.h.

#define mtx_try   4

Definition at line 180 of file tinycthread.h.

#define thrd_busy   3

The requested operation failed because a tesource requested by a test and return function is already in use

Definition at line 174 of file tinycthread.h.

#define thrd_error   0

The requested operation failed

Definition at line 171 of file tinycthread.h.

#define thrd_nomem   4

The requested operation failed because it was unable to allocate memory

Definition at line 175 of file tinycthread.h.

#define thrd_success   1

The requested operation succeeded

Definition at line 172 of file tinycthread.h.

#define thrd_timeout   2

The time specified in the call was reached without acquiring the requested resource

Definition at line 173 of file tinycthread.h.

#define TIME_UTC   0

Definition at line 103 of file tinycthread.h.

#define TINYCTHREAD_VERSION   (TINYCTHREAD_VERSION_MAJOR * 100 + TINYCTHREAD_VERSION_MINOR)

TinyCThread version (full version).

Definition at line 137 of file tinycthread.h.

#define TINYCTHREAD_VERSION_MAJOR   1

TinyCThread version (major number).

Definition at line 133 of file tinycthread.h.

#define TINYCTHREAD_VERSION_MINOR   1

TinyCThread version (minor number).

Definition at line 135 of file tinycthread.h.

#define TSS_DTOR_ITERATIONS   0

Definition at line 168 of file tinycthread.h.

Typedef Documentation

typedef pthread_cond_t cnd_t

Definition at line 252 of file tinycthread.h.

typedef pthread_mutex_t mtx_t

Definition at line 191 of file tinycthread.h.

typedef int(* thrd_start_t) (void *arg)

Thread start function. Any thread that is started with the thrd_create() function must be started through a function of this type.

Parameters
argThe thread argument (the arg argument of the corresponding thrd_create() call).
Returns
The thread return value, which can be obtained by another thread by using the thrd_join() function.

Definition at line 328 of file tinycthread.h.

typedef pthread_t thrd_t

Definition at line 317 of file tinycthread.h.

typedef void(* tss_dtor_t) (void *val)

Destructor function for a thread-specific storage.

Parameters
valThe value of the destructed thread-specific storage.

Definition at line 404 of file tinycthread.h.

typedef pthread_key_t tss_t

Definition at line 398 of file tinycthread.h.

Function Documentation

int cnd_broadcast ( cnd_t cond)

Broadcast a condition variable. Unblocks all of the threads that are blocked on the given condition variable at the time of the call. If no threads are blocked on the condition variable at the time of the call, the function does nothing and return success.

Parameters
condA condition variable object.
Returns
thrd_success on success, or thrd_error if the request could not be honored.

Definition at line 211 of file tinycthread.c.

void cnd_destroy ( cnd_t cond)

Release any resources used by the given condition variable.

Parameters
condA condition variable object.

Definition at line 169 of file tinycthread.c.

int cnd_init ( cnd_t cond)

Create a condition variable object.

Parameters
condA condition variable object.
Returns
thrd_success on success, or thrd_error if the request could not be honored.

Definition at line 140 of file tinycthread.c.

int cnd_signal ( cnd_t cond)

Signal a condition variable. Unblocks one of the threads that are blocked on the given condition variable at the time of the call. If no threads are blocked on the condition variable at the time of the call, the function does nothing and return success.

Parameters
condA condition variable object.
Returns
thrd_success on success, or thrd_error if the request could not be honored.

Definition at line 186 of file tinycthread.c.

int cnd_timedwait ( cnd_t cond,
mtx_t mtx,
const struct timespec *  ts 
)

Wait for a condition variable to become signaled. The function atomically unlocks the given mutex and endeavors to block until the given condition variable is signaled by a call to cnd_signal or to cnd_broadcast, or until after the specified time. When the calling thread becomes unblocked it locks the mutex before it returns.

Parameters
condA condition variable object.
mtxA mutex object.
xtA point in time at which the request will time out (absolute time).
Returns
thrd_success upon success, or thrd_timeout if the time specified in the call was reached without acquiring the requested resource, or thrd_error if the request could not be honored.

Definition at line 294 of file tinycthread.c.

int cnd_wait ( cnd_t cond,
mtx_t mtx 
)

Wait for a condition variable to become signaled. The function atomically unlocks the given mutex and endeavors to block until the given condition variable is signaled by a call to cnd_signal or to cnd_broadcast. When the calling thread becomes unblocked it locks the mutex before it returns.

Parameters
condA condition variable object.
mtxA mutex object.
Returns
thrd_success on success, or thrd_error if the request could not be honored.

Definition at line 285 of file tinycthread.c.

void mtx_destroy ( mtx_t mtx)

Release any resources used by the given mutex.

Parameters
mtxA mutex object.

Definition at line 77 of file tinycthread.c.

int mtx_init ( mtx_t mtx,
int  type 
)

Create a mutex object.

Parameters
mtxA mutex object.
typeBit-mask that must have one of the following six values:
  • mtx_plain for a simple non-recursive mutex
  • mtx_timed for a non-recursive mutex that supports timeout
  • mtx_try for a non-recursive mutex that supports test and return
  • mtx_plain | mtx_recursive (same as mtx_plain, but recursive)
  • mtx_timed | mtx_recursive (same as mtx_timed, but recursive)
  • mtx_try | mtx_recursive (same as mtx_try, but recursive)
Returns
thrd_success on success, or thrd_error if the request could not be honored.

Definition at line 56 of file tinycthread.c.

int mtx_lock ( mtx_t mtx)

Lock the given mutex. Blocks until the given mutex can be locked. If the mutex is non-recursive, and the calling thread already has a lock on the mutex, this call will block forever.

Parameters
mtxA mutex object.
Returns
thrd_success on success, or thrd_error if the request could not be honored.

Definition at line 86 of file tinycthread.c.

int mtx_timedlock ( mtx_t mtx,
const struct timespec *  ts 
)

NOT YET IMPLEMENTED.

Definition at line 101 of file tinycthread.c.

int mtx_trylock ( mtx_t mtx)

Try to lock the given mutex. The specified mutex shall support either test and return or timeout. If the mutex is already locked, the function returns without blocking.

Parameters
mtxA mutex object.
Returns
thrd_success on success, or thrd_busy if the resource requested is already in use, or thrd_error if the request could not be honored.

Definition at line 109 of file tinycthread.c.

int mtx_unlock ( mtx_t mtx)

Unlock the given mutex.

Parameters
mtxA mutex object.
Returns
thrd_success on success, or thrd_error if the request could not be honored.

Definition at line 124 of file tinycthread.c.

int thrd_create ( thrd_t thr,
thrd_start_t  func,
void arg 
)

Create a new thread.

Parameters
thrIdentifier of the newly created thread.
funcA function pointer to the function that will be executed in the new thread.
argAn argument to the thread function.
Returns
thrd_success on success, or thrd_nomem if no memory could be allocated for the thread requested, or thrd_error if the request could not be honored.
Note
A thread’s identifier may be reused for a different thread once the original thread has exited and either been detached or joined to another thread.

Definition at line 361 of file tinycthread.c.

thrd_t thrd_current ( void  )

Identify the calling thread.

Returns
The identifier of the calling thread.

Definition at line 393 of file tinycthread.c.

int thrd_detach ( thrd_t  thr)

NOT YET IMPLEMENTED.

Definition at line 402 of file tinycthread.c.

int thrd_equal ( thrd_t  thr0,
thrd_t  thr1 
)

Compare two thread identifiers. The function determines if two thread identifiers refer to the same thread.

Returns
Zero if the two thread identifiers refer to different threads. Otherwise a nonzero value is returned.

Definition at line 409 of file tinycthread.c.

void thrd_exit ( int  res)

Terminate execution of the calling thread.

Parameters
resResult code of the calling thread.

Definition at line 418 of file tinycthread.c.

int thrd_join ( thrd_t  thr,
int *  res 
)

Wait for a thread to terminate. The function joins the given thread with the current thread by blocking until the other thread has terminated.

Parameters
thrThe thread to join with.
resIf this pointer is not NULL, the function will store the result code of the given thread in the integer pointed to by res.
Returns
thrd_success on success, or thrd_error if the request could not be honored.

Definition at line 432 of file tinycthread.c.

int thrd_sleep ( const struct timespec *  time_point,
struct timespec *  remaining 
)

Put the calling thread to sleep. Suspend execution of the calling thread.

Parameters
time_pointA point in time at which the thread will resume (absolute time).
remainingIf non-NULL, this parameter will hold the remaining time until time_point upon return. This will typically be zero, but if the thread was woken up by a signal that is not ignored before time_point was reached remaining will hold a positive time.
Returns
0 (zero) on successful sleep, or -1 if an interrupt occurred.

Definition at line 465 of file tinycthread.c.

void thrd_yield ( void  )

Yield execution to another thread. Permit other threads to run, even if the current thread would ordinarily continue to run.

Definition at line 512 of file tinycthread.c.

int tss_create ( tss_t key,
tss_dtor_t  dtor 
)

Create a thread-specific storage.

Parameters
keyThe unique key identifier that will be set if the function is successful.
dtorDestructor function. This can be NULL.
Returns
thrd_success on success, or thrd_error if the request could not be honored.
Note
The destructor function is not supported under Windows. If dtor is not NULL when calling this function under Windows, the function will fail and return thrd_error.

Definition at line 521 of file tinycthread.c.

void tss_delete ( tss_t  key)

Delete a thread-specific storage. The function releases any resources used by the given thread-specific storage.

Parameters
keyThe key that shall be deleted.

Definition at line 543 of file tinycthread.c.

void* tss_get ( tss_t  key)

Get the value for a thread-specific storage.

Parameters
keyThe thread-specific storage identifier.
Returns
The value for the current thread held in the given thread-specific storage.

Definition at line 552 of file tinycthread.c.

int tss_set ( tss_t  key,
void val 
)

Set the value for a thread-specific storage.

Parameters
keyThe thread-specific storage identifier.
valThe value of the thread-specific storage to set for the current thread.
Returns
thrd_success on success, or thrd_error if the request could not be honored.

Definition at line 561 of file tinycthread.c.



librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:30