insert a space between the function name and the ( in each function call
This commit is contained in:
parent
9c60d88c56
commit
d63a6066a0
2 changed files with 20 additions and 20 deletions
|
|
@ -47,7 +47,7 @@ lumiera_threadpool_init(void)
|
|||
{
|
||||
for (int i = 0; i < LUMIERA_THREADCLASS_COUNT; ++i)
|
||||
{
|
||||
llist_init(&threadpool.pool[i].list);
|
||||
llist_init (&threadpool.pool[i].list);
|
||||
threadpool.pool[i].working_thread_count = 0;
|
||||
threadpool.pool[i].idle_thread_count = 0;
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ lumiera_threadpool_init(void)
|
|||
pthread_attr_setdetachstate (&threadpool.pool[i].pthread_attrs, PTHREAD_CREATE_DETACHED);
|
||||
//cancel...
|
||||
|
||||
lumiera_mutex_init(&threadpool.pool[i].lock,"pool of threads", &NOBUG_FLAG(threadpool));
|
||||
lumiera_mutex_init (&threadpool.pool[i].lock,"pool of threads", &NOBUG_FLAG (threadpool));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -68,9 +68,9 @@ lumiera_threadpool_destroy(void)
|
|||
{
|
||||
ECHO ("destroying individual pool #%d", i);
|
||||
// no locking is done at this point
|
||||
ECHO ("number of threads in the pool=%d", llist_count(&threadpool.pool[i].list));
|
||||
LLIST_WHILE_HEAD(&threadpool.pool[i].list, thread)
|
||||
lumiera_thread_delete((LumieraThread)thread);
|
||||
ECHO ("number of threads in the pool=%d", llist_count (&threadpool.pool[i].list));
|
||||
LLIST_WHILE_HEAD (&threadpool.pool[i].list, thread)
|
||||
lumiera_thread_delete ((LumieraThread)thread);
|
||||
ECHO ("destroying the pool mutex");
|
||||
lumiera_mutex_destroy (&threadpool.pool[i].lock, &NOBUG_FLAG (threadpool));
|
||||
ECHO ("pool mutex destroyed");
|
||||
|
|
@ -100,14 +100,14 @@ lumiera_threadpool_acquire_thread(enum lumiera_thread_class kind,
|
|||
// remove it from the pool's list
|
||||
LUMIERA_MUTEX_SECTION (threadpool, &threadpool.pool[kind].lock)
|
||||
{
|
||||
ret = (LumieraThread)(llist_unlink(llist_head (&threadpool.pool[kind].list)));
|
||||
ret = (LumieraThread)(llist_unlink (llist_head (&threadpool.pool[kind].list)));
|
||||
threadpool.pool[kind].working_thread_count++;
|
||||
threadpool.pool[kind].idle_thread_count--; // cheaper than using llist_count
|
||||
ENSURE (threadpool.pool[kind].idle_thread_count ==
|
||||
llist_count(&threadpool.pool[kind].list),
|
||||
llist_count (&threadpool.pool[kind].list),
|
||||
"idle thread count %d is wrong, should be %d",
|
||||
threadpool.pool[kind].idle_thread_count,
|
||||
llist_count(&threadpool.pool[kind].list));
|
||||
llist_count (&threadpool.pool[kind].list));
|
||||
}
|
||||
ENSURE (ret, "did not find a valid thread");
|
||||
}
|
||||
|
|
@ -122,15 +122,15 @@ lumiera_threadpool_release_thread(LumieraThread thread)
|
|||
|
||||
LUMIERA_MUTEX_SECTION (threadpool, &threadpool.pool[thread->kind].lock)
|
||||
{
|
||||
REQUIRE (llist_is_single(&thread->node), "thread already belongs to some list");
|
||||
llist_insert_head(&threadpool.pool[thread->kind].list, &thread->node);
|
||||
REQUIRE (llist_is_single (&thread->node), "thread already belongs to some list");
|
||||
llist_insert_head (&threadpool.pool[thread->kind].list, &thread->node);
|
||||
threadpool.pool[thread->kind].working_thread_count--;
|
||||
threadpool.pool[thread->kind].idle_thread_count++; // cheaper than using llist_count
|
||||
ENSURE (threadpool.pool[thread->kind].idle_thread_count ==
|
||||
llist_count(&threadpool.pool[thread->kind].list),
|
||||
llist_count (&threadpool.pool[thread->kind].list),
|
||||
"idle thread count %d is wrong, should be %d",
|
||||
threadpool.pool[thread->kind].idle_thread_count,
|
||||
llist_count(&threadpool.pool[thread->kind].list));
|
||||
llist_count (&threadpool.pool[thread->kind].list));
|
||||
// REQUIRE (!llist_is_empty (&threadpool.pool[thread->kind].list), "thread pool is still empty after insertion");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ const char* lumiera_threadstate_names[] = {
|
|||
|
||||
struct lumiera_thread_mockup
|
||||
{
|
||||
void (*fn)(void*);
|
||||
void (*fn) (void*);
|
||||
void* arg;
|
||||
LumieraReccondition finished;
|
||||
};
|
||||
|
|
@ -86,7 +86,7 @@ static void* pthread_runner (void* thread)
|
|||
if (!thread_end_notification)
|
||||
return NULL; // no signalling of thread termination desired
|
||||
|
||||
LUMIERA_RECCONDITION_SECTION(cond_sync, thread_end_notification)
|
||||
LUMIERA_RECCONDITION_SECTION (cond_sync, thread_end_notification)
|
||||
LUMIERA_RECCONDITION_BROADCAST;
|
||||
|
||||
return NULL;
|
||||
|
|
@ -140,13 +140,13 @@ lumiera_thread_run (enum lumiera_thread_class kind,
|
|||
(void)function;
|
||||
(void)arg;
|
||||
// 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, purpose, flag);
|
||||
|
||||
// TODO: set the function and data to be run
|
||||
// lumiera_thread_set_func_data (self, start_routine, arg, purpose, flag);
|
||||
|
||||
// and let it really run (signal the condition var, the thread waits on it)
|
||||
LUMIERA_RECCONDITION_SECTION(cond_sync, self->finished)
|
||||
LUMIERA_RECCONDITION_SECTION (cond_sync, self->finished)
|
||||
LUMIERA_RECCONDITION_SIGNAL;
|
||||
|
||||
// NOTE: example only, add solid error handling!
|
||||
|
|
@ -174,14 +174,14 @@ lumiera_thread_new (enum lumiera_thread_class kind,
|
|||
|
||||
|
||||
LumieraThread self = lumiera_malloc (sizeof (*self));
|
||||
llist_init(&self->node);
|
||||
llist_init (&self->node);
|
||||
self->finished = finished;
|
||||
self->kind = kind;
|
||||
self->state = LUMIERA_THREADSTATE_IDLE;
|
||||
|
||||
//REQUIRE (thread_loop);
|
||||
int error = pthread_create (&self->id, attrs, &thread_loop, self);
|
||||
ENSURE(error == 0 || EAGAIN == error, "pthread returned %d:%s", error, strerror(error));
|
||||
ENSURE (error == 0 || EAGAIN == error, "pthread returned %d:%s", error, strerror (error));
|
||||
if (error)
|
||||
{
|
||||
// error here can only be EAGAIN, given the above ENSURE
|
||||
|
|
@ -197,9 +197,9 @@ lumiera_thread_destroy (LumieraThread self)
|
|||
REQUIRE (self, "trying to destroy an invalid thread");
|
||||
|
||||
// TODO: stop the pthread
|
||||
llist_unlink(&self->node);
|
||||
llist_unlink (&self->node);
|
||||
//finished = NULL; // or free(finished)?
|
||||
lumiera_reccondition_destroy (self->finished, &NOBUG_FLAG(threads));
|
||||
lumiera_reccondition_destroy (self->finished, &NOBUG_FLAG (threads));
|
||||
//kind = 0;
|
||||
//state = 0;
|
||||
return self;
|
||||
|
|
|
|||
Loading…
Reference in a new issue