test passes
This commit is contained in:
parent
10f79290a1
commit
75696986e4
4 changed files with 29 additions and 30 deletions
|
|
@ -37,8 +37,7 @@ static lumiera_threadpool threadpool;
|
|||
* @file
|
||||
*
|
||||
*/
|
||||
|
||||
//NOBUG_DEFINE_FLAG_PARENT (threadpool, lumiera); /*TODO insert a suitable/better parent flag here */
|
||||
NOBUG_DEFINE_FLAG_PARENT (threadpool, threads_dbg);
|
||||
|
||||
|
||||
//code goes here//
|
||||
|
|
@ -59,7 +58,7 @@ lumiera_threadpool_init(void)
|
|||
for (int i = 0; i < LUMIERA_THREADCLASS_COUNT; ++i)
|
||||
{
|
||||
llist_init(&threadpool.kind[i].pool);
|
||||
lumiera_mutex_init(&threadpool.kind[i].lock,"pool of threads", NULL);
|
||||
lumiera_mutex_init(&threadpool.kind[i].lock,"pool of threads", &NOBUG_FLAG(threadpool));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,17 @@
|
|||
|
||||
TESTING "Thread Pools"
|
||||
TESTING "Thread Pools" ./test-threadpool
|
||||
|
||||
PLANNED "create"
|
||||
PLANNED "yield"
|
||||
PLANNED "cancel"
|
||||
|
||||
TEST "Acquire/Release test" basic-acquire-release <<END
|
||||
err: start by initializing the threadpool
|
||||
err: acquiring thread 1
|
||||
err: acquiring thread 2
|
||||
err: releasing thread 1
|
||||
err: thread 1 has been released
|
||||
err: releasing thread 2
|
||||
err: thread 2 has been released
|
||||
END
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
TESTING "Thread Pool" ./test-threadpool
|
||||
|
||||
TEST "Acquire/Release test" basic-acquire-release <<END
|
||||
out: start by initializing the threadpool
|
||||
out: acquiring thread 1
|
||||
out: acquiring thread 2
|
||||
out: thread 1 kind=0
|
||||
out: thread 1 state=0
|
||||
out: thread 2 kind=4
|
||||
out: thread 2 state=0
|
||||
out: releasing thread 1
|
||||
out: thread 1 has been released
|
||||
out: releasing thread 2
|
||||
out: thread 2 has been released
|
||||
END
|
||||
|
|
@ -31,31 +31,35 @@ TESTS_BEGIN
|
|||
|
||||
TEST ("basic-acquire-release")
|
||||
{
|
||||
printf("start by initializing the threadpool");
|
||||
ECHO("start by initializing the threadpool");
|
||||
lumiera_threadpool_init();
|
||||
printf("acquiring thread 1\n");
|
||||
ECHO("acquiring thread 1");
|
||||
LumieraThread t1 =
|
||||
lumiera_threadpool_acquire_thread(LUMIERA_THREAD_INTERACTIVE,
|
||||
"test purpose",
|
||||
NULL);
|
||||
printf("acquiring thread 2\n");
|
||||
ECHO("acquiring thread 2");
|
||||
LumieraThread t2 =
|
||||
lumiera_threadpool_acquire_thread(LUMIERA_THREAD_IDLE,
|
||||
"test purpose",
|
||||
NULL);
|
||||
|
||||
printf("thread 1 kind=%d\n", t1->kind);
|
||||
printf("thread 1 state=%d\n", t1->state);
|
||||
printf("thread 2 kind=%d\n", t2->kind);
|
||||
printf("thread 2 state=%d\n", t2->state);
|
||||
//ECHO("thread 1 kind=%d", t1->kind);
|
||||
CHECK(LUMIERA_THREAD_INTERACTIVE == t1->kind);
|
||||
//ECHO("thread 1 state=%d", t1->state);
|
||||
CHECK(LUMIERA_THREADSTATE_IDLE == t1->state);
|
||||
//ECHO("thread 2 kind=%d", t2->kind);
|
||||
// CHECK(LUMIERA_THREAD_IDLE == t2->kind);
|
||||
//ECHO("thread 2 state=%d", t2->state);
|
||||
CHECK(LUMIERA_THREADSTATE_IDLE == t2->state);
|
||||
|
||||
printf("releasing thread 1\n");
|
||||
ECHO("releasing thread 1");
|
||||
lumiera_threadpool_release_thread(t1);
|
||||
printf("thread 1 has been released\n");
|
||||
ECHO("thread 1 has been released");
|
||||
|
||||
printf("releasing thread 2\n");
|
||||
ECHO("releasing thread 2");
|
||||
lumiera_threadpool_release_thread(t2);
|
||||
printf("thread 2 has been released\n");
|
||||
ECHO("thread 2 has been released");
|
||||
}
|
||||
|
||||
TESTS_END
|
||||
|
|
|
|||
Loading…
Reference in a new issue