Libmacro  0.2
Libmacro is an extensible macro and hotkey library.
cppthread.h File Reference
#include "mcr/globals.h"

Go to the source code of this file.

Classes

struct  mtx_t
 

Typedefs

typedef int once_flag
 
typedef int(* thrd_start_t) (void *)
 
typedef void * thrd_t
 
typedef void * cnd_t
 

Enumerations

enum  {
  thrd_success = 0, thrd_nomem, thrd_timedout, thrd_busy,
  thrd_error
}
 
enum  { mtx_plain = 0, mtx_recursive = 1 << 0, mtx_timed = 1 << 1 }
 

Functions

MCR_API int thrd_sleep_until (struct tm *time_point)
 
MCR_API int thrd_create (thrd_t *thr, thrd_start_t func, void *arg)
 
MCR_API int thrd_equal (thrd_t lhs, thrd_t rhs)
 
MCR_API thrd_t thrd_current ()
 
MCR_API int thrd_sleep (const struct timespec *time_point, struct timespec *remaining)
 
MCR_API void thrd_yield ()
 
void thrd_exit (int res)
 
MCR_API int thrd_detach (thrd_t thr)
 
MCR_API int thrd_join (thrd_t thr, int *res)
 
MCR_API void mcr_thrd_delete (thrd_t *thr)
 
MCR_API int mtx_init (mtx_t *mutex, int type)
 
MCR_API int mtx_lock (mtx_t *mutex)
 
MCR_API int mtx_timedlock (mtx_t *mutex, const struct timespec *time_point)
 
MCR_API int mtx_trylock (mtx_t *mutex)
 
MCR_API int mtx_unlock (mtx_t *mutex)
 
MCR_API void mtx_destroy (mtx_t *mutex)
 
MCR_API int cnd_init (cnd_t *cond)
 
MCR_API int cnd_signal (cnd_t *cond)
 
MCR_API int cnd_broadcast (cnd_t *cond)
 
MCR_API int cnd_wait (cnd_t *cond, mtx_t *mutex)
 
MCR_API int cnd_timedwait (cnd_t *cond, mtx_t *mutex, const struct timespec *time_point)
 
MCR_API void cnd_destroy (cnd_t *cond)
 

Detailed Description

Temporary solution. Until threading is implemented in C we have to use either C++ or native threading. For standard C reference please use a C11 reference.

Definition in file cppthread.h.

Function Documentation

§ cnd_timedwait()

MCR_API int cnd_timedwait ( cnd_t *  cond,
mtx_t mutex,
const struct timespec time_point 
)

Pre: mutex must be mtx_plain.

§ cnd_wait()

MCR_API int cnd_wait ( cnd_t *  cond,
mtx_t mutex 
)

Pre: mutex must be mtx_plain.

§ thrd_sleep_until()

MCR_API int thrd_sleep_until ( struct tm *  time_point)

Sleep current thread until given time.