it is more proper to use cond_sync flags for *CONDITION_SECTIONs

This commit is contained in:
Michael Ploujnikov 2010-01-31 20:36:02 -05:00
parent b799321dff
commit 8588fa2b9c
3 changed files with 11 additions and 11 deletions

View file

@ -68,13 +68,13 @@ lumiera_threadpool_destroy(void)
/* set all threadpools offline must be done first, since running threads may attempt to start new ones */
for (int i = 0; i < LUMIERA_THREADCLASS_COUNT; ++i)
LUMIERA_CONDITION_SECTION (threadpool, &threadpool.pool[i].sync)
LUMIERA_CONDITION_SECTION (cond_sync, &threadpool.pool[i].sync)
threadpool.pool[i].status = LUMIERA_THREADPOOL_OFFLINE;
/* wait that all theads have finished */
for (int i = 0; i < LUMIERA_THREADCLASS_COUNT; ++i)
{
LUMIERA_CONDITION_SECTION (threadpool, &threadpool.pool[i].sync)
LUMIERA_CONDITION_SECTION (cond_sync, &threadpool.pool[i].sync)
{
TODO ("check threads deadlines, kill them when they are stalled");
TODO ("for threads without deadline use a timeout from config system, 500ms or so by default");
@ -87,7 +87,7 @@ lumiera_threadpool_destroy(void)
{
TRACE (threadpool, "destroying individual pool #%d", i);
LUMIERA_CONDITION_SECTION (threadpool, &threadpool.pool[i].sync)
LUMIERA_CONDITION_SECTION (cond_sync, &threadpool.pool[i].sync)
{
ENSURE (llist_is_empty (&threadpool.pool[i].working_list),
"threads are still running");
@ -116,7 +116,7 @@ lumiera_threadpool_acquire_thread (enum lumiera_thread_class kind,
REQUIRE (kind < LUMIERA_THREADCLASS_COUNT, "unknown pool kind specified: %d", kind);
LUMIERA_CONDITION_SECTION (threadpool, &threadpool.pool[kind].sync)
LUMIERA_CONDITION_SECTION (cond_sync, &threadpool.pool[kind].sync)
{
if (threadpool.pool[kind].status != LUMIERA_THREADPOOL_ONLINE)
LUMIERA_ERROR_SET_WARNING (threadpool, THREADPOOL_OFFLINE, purpose);
@ -162,7 +162,7 @@ lumiera_threadpool_release_thread(LumieraThread thread)
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");
LUMIERA_CONDITION_SECTION (threadpool, &threadpool.pool[thread->kind].sync)
LUMIERA_CONDITION_SECTION (cond_sync, &threadpool.pool[thread->kind].sync)
{
REQUIRE (!llist_is_member (&threadpool.pool[thread->kind].idle_list, &thread->node), "thread is already in the idle list");
REQUIRE (llist_is_member (&threadpool.pool[thread->kind].working_list, &thread->node)

View file

@ -86,7 +86,7 @@ thread_loop (void* thread)
REQUIRE (t, "thread does not exist");
LUMIERA_CONDITION_SECTION (threads, &t->signal)
LUMIERA_CONDITION_SECTION (cond_sync, &t->signal)
{
t->rh = &lumiera_lock_section_.rh;
@ -198,7 +198,7 @@ lumiera_thread_destroy (LumieraThread self)
// get the pthread out of the processing loop
// need to signal to the thread that it should start quitting
// should this be within the section?
LUMIERA_CONDITION_SECTION (threads, &self->signal)
LUMIERA_CONDITION_SECTION (cond_sync, &self->signal)
{
REQUIRE (self->state == LUMIERA_THREADSTATE_IDLE, "trying to delete a thread in state other than IDLE (%s)", lumiera_threadstate_names[self->state]);
self->state = LUMIERA_THREADSTATE_SHUTDOWN;
@ -299,7 +299,7 @@ lumiera_thread_sync_other (LumieraThread other)
{
TRACE(threads);
LUMIERA_CONDITION_SECTION (threads, &other->signal)
LUMIERA_CONDITION_SECTION (cond_sync, &other->signal)
{
LUMIERA_CONDITION_WAIT (other->state == LUMIERA_THREADSTATE_SYNCING);
other->state = LUMIERA_THREADSTATE_RUNNING;
@ -337,7 +337,7 @@ lumiera_thread_join (LumieraThread thread)
TRACE(threads);
lumiera_err ret = NULL;
LUMIERA_CONDITION_SECTION (threads, &thread->signal)
LUMIERA_CONDITION_SECTION (cond_sync, &thread->signal)
{
LUMIERA_CONDITION_WAIT (thread->state == LUMIERA_THREADSTATE_ZOMBIE);
ret = (lumiera_err)thread->arguments;

View file

@ -99,13 +99,13 @@ TEST ("two-thread-acquire")
ECHO("thread 2 state=%s", lumiera_threadstate_names[t2->state]);
CHECK(LUMIERA_THREADSTATE_IDLE == t2->state);
LUMIERA_CONDITION_SECTION(NOBUG_ON, &t1->signal)
LUMIERA_CONDITION_SECTION(cond_sync, &t1->signal)
{
t1->state = LUMIERA_THREADSTATE_WAKEUP;
LUMIERA_CONDITION_SIGNAL;
}
LUMIERA_CONDITION_SECTION(NOBUG_ON, &t2->signal)
LUMIERA_CONDITION_SECTION(cond_sync, &t2->signal)
{
t2->state = LUMIERA_THREADSTATE_WAKEUP;
LUMIERA_CONDITION_SIGNAL;