@@ -25,10 +25,11 @@ #import "OFObject.h" #if defined(OF_HAVE_PTHREADS) # include +# include typedef pthread_t of_thread_t; typedef pthread_key_t of_tlskey_t; typedef pthread_mutex_t of_mutex_t; typedef pthread_cond_t of_condition_t; typedef pthread_once_t of_once_t; @@ -63,19 +64,28 @@ #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) typedef pthread_spinlock_t of_spinlock_t; #else typedef of_mutex_t of_spinlock_t; #endif + +#ifdef OF_HAVE_SCHED_YIELD +# include +#endif #ifdef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES # define of_rmutex_t of_mutex_t #else typedef struct { of_mutex_t mutex; of_tlskey_t count; } of_rmutex_t; #endif + +typedef struct of_thread_attr_t { + float priority; + size_t stackSize; +} of_thread_attr_t; #if defined(OF_HAVE_PTHREADS) # define of_thread_is_current(t) pthread_equal(t, pthread_self()) # define of_thread_current pthread_self #elif defined(_WIN32) @@ -84,11 +94,13 @@ #else # error of_thread_is_current not implemented! # error of_thread_current not implemented! #endif -extern bool of_thread_new(of_thread_t *thread, id (*function)(id), id data); +extern bool of_thread_attr_init(of_thread_attr_t *attr); +extern bool of_thread_new(of_thread_t *thread, id (*function)(id), id data, + const of_thread_attr_t *attr); extern void of_thread_set_name(of_thread_t thread, const char *name); extern bool of_thread_join(of_thread_t thread); extern bool of_thread_detach(of_thread_t thread); extern void OF_NO_RETURN of_thread_exit(void); extern void of_once(of_once_t *control, void (*func)(void));