aboutsummaryrefslogtreecommitdiff
path: root/src/threading.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/threading.h')
-rw-r--r--src/threading.h84
1 files changed, 41 insertions, 43 deletions
diff --git a/src/threading.h b/src/threading.h
index d87bba6..0698355 100644
--- a/src/threading.h
+++ b/src/threading.h
@@ -184,26 +184,25 @@ bool_t SIGNAL_WAIT( SIGNAL_T *ref, MUTEX_T *mu, time_d timeout );
184 184
185#if THREADAPI == THREADAPI_WINDOWS 185#if THREADAPI == THREADAPI_WINDOWS
186 186
187 typedef HANDLE THREAD_T; 187 typedef HANDLE THREAD_T;
188# define THREAD_ISNULL( _h) (_h == 0) 188# define THREAD_ISNULL( _h) (_h == 0)
189 // 189 void THREAD_CREATE( THREAD_T* ref, THREAD_RETURN_T (__stdcall *func)( void*), void* data, int prio /* -3..+3 */);
190 void THREAD_CREATE( THREAD_T *ref,
191 THREAD_RETURN_T (__stdcall *func)( void * ),
192 void *data, int prio /* -3..+3 */ );
193 190
194# define THREAD_PRIO_MIN (-3) 191# define THREAD_PRIO_MIN (-3)
195# define THREAD_PRIO_MAX (+3) 192# define THREAD_PRIO_MAX (+3)
196 193
197#define THREAD_CLEANUP_PUSH( cb_, val_) 194# define THREAD_CLEANUP_PUSH( cb_, val_)
198#define THREAD_CLEANUP_POP( execute_) 195# define THREAD_CLEANUP_POP( execute_)
199 196
200#else // THREADAPI == THREADAPI_PTHREAD 197#else // THREADAPI == THREADAPI_PTHREAD
201 /* Platforms that have a timed 'pthread_join()' can get away with a simpler 198
202 * implementation. Others will use a condition variable. 199 /* Platforms that have a timed 'pthread_join()' can get away with a simpler
203 */ 200 * implementation. Others will use a condition variable.
204#if defined __WINPTHREADS_VERSION 201 */
205//#define USE_PTHREAD_TIMEDJOIN 202# if defined __WINPTHREADS_VERSION
206#endif // __WINPTHREADS_VERSION 203//# define USE_PTHREAD_TIMEDJOIN
204# endif // __WINPTHREADS_VERSION
205
207# ifdef USE_PTHREAD_TIMEDJOIN 206# ifdef USE_PTHREAD_TIMEDJOIN
208# ifdef PLATFORM_OSX 207# ifdef PLATFORM_OSX
209# error "No 'pthread_timedjoin()' on this system" 208# error "No 'pthread_timedjoin()' on this system"
@@ -213,33 +212,31 @@ bool_t SIGNAL_WAIT( SIGNAL_T *ref, MUTEX_T *mu, time_d timeout );
213# endif 212# endif
214# endif 213# endif
215 214
216 typedef pthread_t THREAD_T; 215 typedef pthread_t THREAD_T;
217# define THREAD_ISNULL( _h) 0 // pthread_t may be a structure: never 'null' by itself 216# define THREAD_ISNULL( _h) 0 // pthread_t may be a structure: never 'null' by itself
218 217
219 void THREAD_CREATE( THREAD_T *ref, 218 void THREAD_CREATE( THREAD_T* ref, THREAD_RETURN_T (*func)( void*), void* data, int prio /* -3..+3 */);
220 THREAD_RETURN_T (*func)( void * ), 219
221 void *data, int prio /* -2..+2 */ ); 220# if defined(PLATFORM_LINUX)
222 221 extern volatile bool_t sudo;
223# if defined(PLATFORM_LINUX) 222# ifdef LINUX_SCHED_RR
224 extern volatile bool_t sudo; 223# define THREAD_PRIO_MIN (sudo ? -3 : 0)
225# ifdef LINUX_SCHED_RR 224# else
226# define THREAD_PRIO_MIN (sudo ? -3 : 0) 225# define THREAD_PRIO_MIN (0)
227# else 226# endif
228# define THREAD_PRIO_MIN (0) 227# define THREAD_PRIO_MAX (sudo ? +3 : 0)
229# endif 228# else
230# define THREAD_PRIO_MAX (sudo ? +3 : 0) 229# define THREAD_PRIO_MIN (-3)
231# else 230# define THREAD_PRIO_MAX (+3)
232# define THREAD_PRIO_MIN (-3) 231# endif
233# define THREAD_PRIO_MAX (+3) 232
234# endif 233# if THREADWAIT_METHOD == THREADWAIT_CONDVAR
235 234# define THREAD_CLEANUP_PUSH( cb_, val_) pthread_cleanup_push( cb_, val_)
236#if THREADWAIT_METHOD == THREADWAIT_CONDVAR 235# define THREAD_CLEANUP_POP( execute_) pthread_cleanup_pop( execute_)
237#define THREAD_CLEANUP_PUSH( cb_, val_) pthread_cleanup_push( cb_, val_) 236# else
238#define THREAD_CLEANUP_POP( execute_) pthread_cleanup_pop( execute_) 237# define THREAD_CLEANUP_PUSH( cb_, val_) {
239#else 238# define THREAD_CLEANUP_POP( execute_) }
240#define THREAD_CLEANUP_PUSH( cb_, val_) { 239# endif // THREADWAIT_METHOD == THREADWAIT_CONDVAR
241#define THREAD_CLEANUP_POP( execute_) }
242#endif // THREADWAIT_METHOD == THREADWAIT_CONDVAR
243#endif // THREADAPI == THREADAPI_WINDOWS 240#endif // THREADAPI == THREADAPI_WINDOWS
244 241
245/* 242/*
@@ -267,5 +264,6 @@ bool_t THREAD_WAIT_IMPL( THREAD_T *ref, double secs, SIGNAL_T *signal_ref, MUTEX
267void THREAD_KILL( THREAD_T* ref); 264void THREAD_KILL( THREAD_T* ref);
268void THREAD_SETNAME( char const* _name); 265void THREAD_SETNAME( char const* _name);
269void THREAD_MAKE_ASYNCH_CANCELLABLE(); 266void THREAD_MAKE_ASYNCH_CANCELLABLE();
267void THREAD_SET_PRIORITY( int prio);
270 268
271#endif // __threading_h__ 269#endif // __threading_h__