thread kind and flag handling
* 256 states are enough for anyone (else fix the source) * add proper masking and handling of flags
This commit is contained in:
parent
32217debe8
commit
12968bb784
3 changed files with 8 additions and 7 deletions
|
|
@ -179,6 +179,7 @@ lumiera_threadpool_release_thread(LumieraThread thread)
|
|||
{
|
||||
TRACE (threadpool);
|
||||
REQUIRE (thread, "invalid thread given");
|
||||
thread->kind = thread->kind&0xff;
|
||||
REQUIRE (thread->kind < LUMIERA_THREADCLASS_COUNT, "thread belongs to an unknown pool kind: %d", thread->kind);
|
||||
|
||||
REQUIRE (thread->state != LUMIERA_THREADSTATE_IDLE, "trying to park an already idle thread");
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ thread_loop (void* thread)
|
|||
// when this is called it should have already been decided that the function
|
||||
// shall run in parallel, as a thread
|
||||
LumieraThread
|
||||
lumiera_thread_run (enum lumiera_thread_class kind,
|
||||
lumiera_thread_run (int kind,
|
||||
void (*function)(void *),
|
||||
void * arg,
|
||||
const char* purpose,
|
||||
|
|
@ -136,12 +136,12 @@ lumiera_thread_run (enum lumiera_thread_class kind,
|
|||
// REQUIRE (function, "invalid function");
|
||||
|
||||
// ask the threadpool for a thread (it might create a new one)
|
||||
LumieraThread self = lumiera_threadpool_acquire_thread (kind, purpose, flag);
|
||||
LumieraThread self = lumiera_threadpool_acquire_thread (kind&0xff, purpose, flag);
|
||||
|
||||
// set the function and data to be run
|
||||
self->function = function;
|
||||
self->arguments = arg;
|
||||
|
||||
self->kind = kind;
|
||||
self->deadline.tv_sec = 0;
|
||||
|
||||
// and let it really run (signal the condition var, the thread waits on it)
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ enum lumiera_thread_class
|
|||
LUMIERA_THREAD_CLASSES
|
||||
/** this just denotes the number of classes listed above,
|
||||
it is used to create arrays **/
|
||||
LUMIERA_THREADCLASS_COUNT,
|
||||
LUMIERA_THREADCLASS_COUNT, /* must be <= 256, thats easy or? */
|
||||
|
||||
// .. various thread flags follow
|
||||
/**
|
||||
|
|
@ -83,12 +83,12 @@ enum lumiera_thread_class
|
|||
* The Thread must be very careful with locking, better don't.
|
||||
* TODO explain syncronization issues
|
||||
**/
|
||||
LUMIERA_THREAD_OR_NOT = 1<<16,
|
||||
LUMIERA_THREAD_OR_NOT = 1<<8,
|
||||
|
||||
/**
|
||||
* Thread must be joined finally
|
||||
**/
|
||||
LUMIERA_THREAD_JOINABLE = 1<<17
|
||||
LUMIERA_THREAD_JOINABLE = 1<<9
|
||||
};
|
||||
|
||||
#undef LUMIERA_THREAD_CLASS
|
||||
|
|
@ -195,7 +195,7 @@ lumiera_thread_delete (LumieraThread self);
|
|||
* @param flag NoBug flag used for logging the thread startup and return
|
||||
*/
|
||||
LumieraThread
|
||||
lumiera_thread_run (enum lumiera_thread_class kind,
|
||||
lumiera_thread_run (int kind,
|
||||
void (*function)(void *),
|
||||
void * arg,
|
||||
const char* purpose,
|
||||
|
|
|
|||
Loading…
Reference in a new issue