gwion-util
utilities for the Gwion project
Loading...
Searching...
No Matches
gwion_thread.h File Reference

cross-platform thread functions More...

#include <pthread.h>
#include <dlfcn.h>

Go to the source code of this file.

Macros

#define THREAD_RETTYPE   void *
 
#define THREAD_FUNC(a)
 
#define THREAD_TYPE   pthread_t
 
#define THREAD_CREATE(thread, func, arg)
 
#define THREAD_JOIN(thread)
 
#define THREAD_RETURN(arg)
 
#define THREAD_DETACH(arg)
 
#define MUTEX_TYPE   pthread_mutex_t *
 
#define MUTEX_INITIALIZER   PTHREAD_MUTEX_INITIALIZER
 
#define MUTEX_SETUP(x)
 
#define MUTEX_CLEANUP(x)
 
#define MUTEX_LOCK(x)
 
#define MUTEX_COND_LOCK(x)
 
#define MUTEX_UNLOCK(x)
 
#define MUTEX_COND_UNLOCK(x)
 
#define THREAD_COND_TYPE   pthread_cond_t*
 
#define THREAD_COND_SETUP(x)
 
#define THREAD_COND_WAIT(x, mutex)
 
#define THREAD_COND_SIGNAL(x)
 
#define THREAD_COND_BROADCAST(x)
 
#define THREAD_COND_CLEANUP(x)
 
#define STR_EXPAND(tok)
 
#define STR(tok)
 
#define DLOPEN(dl, b)
 
#define DLSYM(dl, t, a)
 
#define DLCLOSE(dl)
 
#define DLERROR()
 

Detailed Description

cross-platform thread functions

Definition in file gwion_thread.h.

Macro Definition Documentation

◆ DLCLOSE

#define DLCLOSE ( dl)
Value:
dlclose(dl)

Definition at line 92 of file gwion_thread.h.

◆ DLERROR

#define DLERROR ( )
Value:
dlerror()

Definition at line 93 of file gwion_thread.h.

◆ DLOPEN

#define DLOPEN ( dl,
b )
Value:
dlopen(dl, b)

Definition at line 90 of file gwion_thread.h.

◆ DLSYM

#define DLSYM ( dl,
t,
a )
Value:
(t)(intptr_t) dlsym(dl, a)

Definition at line 91 of file gwion_thread.h.

◆ MUTEX_CLEANUP

#define MUTEX_CLEANUP ( x)
Value:
{ \
pthread_mutex_destroy((x)); \
xfree(x); \
}

Definition at line 59 of file gwion_thread.h.

59#define MUTEX_CLEANUP(x) \
60 { \
61 pthread_mutex_destroy((x)); \
62 xfree(x); \
63 }

◆ MUTEX_COND_LOCK

#define MUTEX_COND_LOCK ( x)
Value:
pthread_mutex_lock((x))

Definition at line 65 of file gwion_thread.h.

◆ MUTEX_COND_UNLOCK

#define MUTEX_COND_UNLOCK ( x)
Value:
pthread_mutex_unlock((x))

Definition at line 67 of file gwion_thread.h.

◆ MUTEX_INITIALIZER

#define MUTEX_INITIALIZER   PTHREAD_MUTEX_INITIALIZER

Definition at line 50 of file gwion_thread.h.

◆ MUTEX_LOCK

#define MUTEX_LOCK ( x)
Value:
pthread_mutex_lock((x))

Definition at line 64 of file gwion_thread.h.

◆ MUTEX_SETUP

#define MUTEX_SETUP ( x)
Value:
{ \
pthread_mutexattr_t attr; \
pthread_mutexattr_init(&attr); \
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); \
x = (pthread_mutex_t *)xmalloc(sizeof(pthread_mutex_t)); \
pthread_mutex_init(x, &attr); \
}
static ANEW void * xmalloc(const m_uint sz)
Definition xalloc.h:13

Definition at line 51 of file gwion_thread.h.

51#define MUTEX_SETUP(x) \
52 { \
53 pthread_mutexattr_t attr; \
54 pthread_mutexattr_init(&attr); \
55 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); \
56 x = (pthread_mutex_t *)xmalloc(sizeof(pthread_mutex_t)); \
57 pthread_mutex_init(x, &attr); \
58 }

◆ MUTEX_TYPE

#define MUTEX_TYPE   pthread_mutex_t *

Definition at line 49 of file gwion_thread.h.

◆ MUTEX_UNLOCK

#define MUTEX_UNLOCK ( x)
Value:
pthread_mutex_unlock((x))

Definition at line 66 of file gwion_thread.h.

◆ STR

#define STR ( tok)
Value:
#define STR_EXPAND(tok)

Definition at line 87 of file gwion_thread.h.

◆ STR_EXPAND

#define STR_EXPAND ( tok)
Value:
#tok

Definition at line 86 of file gwion_thread.h.

◆ THREAD_COND_BROADCAST

#define THREAD_COND_BROADCAST ( x)
Value:
pthread_cond_broadcast(x)

Definition at line 77 of file gwion_thread.h.

◆ THREAD_COND_CLEANUP

#define THREAD_COND_CLEANUP ( x)
Value:
{ \
pthread_cond_destroy(x); \
xfree(x); \
}

Definition at line 78 of file gwion_thread.h.

78#define THREAD_COND_CLEANUP(x) \
79 { \
80 pthread_cond_destroy(x); \
81 xfree(x); \
82 }

◆ THREAD_COND_SETUP

#define THREAD_COND_SETUP ( x)
Value:
{ \
x = (pthread_cond_t *)xcalloc(1, sizeof(pthread_cond_t)); \
pthread_cond_init(x, NULL); \
}
static ANEW void * xcalloc(const m_uint n, const m_uint sz)
Definition xalloc.h:18

Definition at line 70 of file gwion_thread.h.

70#define THREAD_COND_SETUP(x) \
71 { \
72 x = (pthread_cond_t *)xcalloc(1, sizeof(pthread_cond_t)); \
73 pthread_cond_init(x, NULL); \
74 }

◆ THREAD_COND_SIGNAL

#define THREAD_COND_SIGNAL ( x)
Value:
pthread_cond_signal(x)

Definition at line 76 of file gwion_thread.h.

◆ THREAD_COND_TYPE

#define THREAD_COND_TYPE   pthread_cond_t*

Definition at line 69 of file gwion_thread.h.

◆ THREAD_COND_WAIT

#define THREAD_COND_WAIT ( x,
mutex )
Value:
pthread_cond_wait(x, mutex)

Definition at line 75 of file gwion_thread.h.

◆ THREAD_CREATE

#define THREAD_CREATE ( thread,
func,
arg )
Value:
pthread_create(&thread, NULL, func, arg)
void void * arg
Definition threadpool.h:26

Definition at line 39 of file gwion_thread.h.

39#define THREAD_CREATE(thread, func, arg) \
40 pthread_create(&thread, NULL, func, arg)

◆ THREAD_DETACH

#define THREAD_DETACH ( arg)
Value:
pthread_detach(arg)

Definition at line 47 of file gwion_thread.h.

◆ THREAD_FUNC

#define THREAD_FUNC ( a)
Value:
THREAD_RETTYPE(a)(void *data)
#define THREAD_RETTYPE

Definition at line 37 of file gwion_thread.h.

◆ THREAD_JOIN

#define THREAD_JOIN ( thread)
Value:
pthread_join(thread, NULL)

Definition at line 41 of file gwion_thread.h.

◆ THREAD_RETTYPE

#define THREAD_RETTYPE   void *

Definition at line 36 of file gwion_thread.h.

◆ THREAD_RETURN

#define THREAD_RETURN ( arg)
Value:
{ \
pthread_exit(NULL); \
return NULL; \
}

Definition at line 42 of file gwion_thread.h.

42#define THREAD_RETURN(arg) \
43 { \
44 pthread_exit(NULL); \
45 return NULL; \
46 }

◆ THREAD_TYPE

#define THREAD_TYPE   pthread_t

Definition at line 38 of file gwion_thread.h.