joinable thread sync test
Right now causes 32bytes to be lost
This commit is contained in:
parent
73f1bbae2a
commit
bd6ed5aa88
2 changed files with 50 additions and 0 deletions
|
|
@ -36,4 +36,10 @@ err: result is 0
|
|||
err: value is 84
|
||||
END
|
||||
|
||||
TEST "sync joinable" sync-joinable <<END
|
||||
err: syncing with the master thread
|
||||
err: the master thread received its arguments
|
||||
err: the master thread terminated
|
||||
END
|
||||
|
||||
PLANNED "error cleared on join"
|
||||
|
|
|
|||
|
|
@ -73,6 +73,28 @@ void sleeping_worker_fn(void * arg)
|
|||
ECHO ("result is %d", input);
|
||||
}
|
||||
|
||||
void joinable_worker_fn(void * arg)
|
||||
{
|
||||
int input = *(int *)arg;
|
||||
lumiera_thread_sync ();
|
||||
input += 42;
|
||||
}
|
||||
|
||||
void joinable_master_fn(void * arg)
|
||||
{
|
||||
int input = *(int *)arg;
|
||||
lumiera_thread_sync ();
|
||||
input -= 42;
|
||||
LumieraThread worker = lumiera_thread_run (LUMIERA_THREADCLASS_IDLE
|
||||
| LUMIERA_THREAD_JOINABLE,
|
||||
&joinable_worker_fn,
|
||||
(void *)&input,
|
||||
"joinable worker thread",
|
||||
&NOBUG_FLAG (test));
|
||||
lumiera_thread_sync_other (worker);
|
||||
lumiera_thread_join (worker);
|
||||
}
|
||||
|
||||
TESTS_BEGIN
|
||||
|
||||
TEST ("threadpool-basic")
|
||||
|
|
@ -287,4 +309,26 @@ TEST ("sync-many")
|
|||
lumiera_threadpool_destroy ();
|
||||
}
|
||||
|
||||
TEST ("sync-joinable")
|
||||
{
|
||||
lumiera_threadpool_init ();
|
||||
|
||||
int value = 0;
|
||||
|
||||
LumieraThread master = lumiera_thread_run (LUMIERA_THREADCLASS_IDLE
|
||||
| LUMIERA_THREAD_JOINABLE,
|
||||
&joinable_master_fn,
|
||||
(void *)&value,
|
||||
"joinable master thread",
|
||||
&NOBUG_FLAG (test));
|
||||
|
||||
ECHO ("syncing with the master thread");
|
||||
lumiera_thread_sync_other (master);
|
||||
ECHO ("the master thread received its arguments");
|
||||
lumiera_thread_join (master);
|
||||
ECHO ("the master thread terminated");
|
||||
|
||||
lumiera_threadpool_destroy ();
|
||||
}
|
||||
|
||||
TESTS_END
|
||||
|
|
|
|||
Loading…
Reference in a new issue