Make the thread queue walk function take a cookie to the callback
and implement a _clear() function to clear out the queue
This commit is contained in:
+10
-9
@@ -50,7 +50,7 @@ START_TEST (test_thread_queue_one_thread)
|
||||
fail_if(my_msg->a != i);
|
||||
free(my_msg);
|
||||
}
|
||||
fail_if(uc_thread_queue_destroy(&queue, NULL) != 0);
|
||||
fail_if(uc_thread_queue_destroy(&queue, NULL, NULL) != 0);
|
||||
|
||||
END_TEST
|
||||
|
||||
@@ -59,8 +59,9 @@ END_TEST
|
||||
|
||||
//pretty ugly..
|
||||
static int test_thread_queue_walk_global;
|
||||
static void test_thread_queue_walk_func(struct uc_threadmsg *msg)
|
||||
static void test_thread_queue_walk_func(struct uc_threadmsg *msg, void *cookie)
|
||||
{
|
||||
(void)cookie;
|
||||
struct thr_msg *my_msg = (struct thr_msg *)msg;
|
||||
fail_if(my_msg->a != test_thread_queue_walk_global);
|
||||
test_thread_queue_walk_global++;
|
||||
@@ -82,7 +83,7 @@ START_TEST (test_thread_queue_walk)
|
||||
|
||||
test_thread_queue_walk_global = 0;
|
||||
|
||||
uc_thread_queue_walk(&queue, test_thread_queue_walk_func);
|
||||
uc_thread_queue_walk(&queue, test_thread_queue_walk_func, NULL);
|
||||
|
||||
END_TEST
|
||||
|
||||
@@ -125,7 +126,7 @@ START_TEST (test_thread_queue_reader_writer)
|
||||
|
||||
pthread_join(tid, NULL);
|
||||
|
||||
fail_if(uc_thread_queue_destroy(&queue, NULL) != 0);
|
||||
fail_if(uc_thread_queue_destroy(&queue, NULL, NULL) != 0);
|
||||
|
||||
END_TEST
|
||||
|
||||
@@ -216,7 +217,7 @@ START_TEST (test_thread_queue_timeout1)
|
||||
fail_if(uc_thread_queue_init(&queue, 100) != 0);
|
||||
|
||||
fail_if(uc_thread_queue_tryget(&queue, &timeout, &msg) != ETIMEDOUT);
|
||||
uc_thread_queue_destroy(&queue, NULL);
|
||||
uc_thread_queue_destroy(&queue, NULL, NULL);
|
||||
|
||||
END_TEST
|
||||
|
||||
@@ -251,7 +252,7 @@ START_TEST (test_thread_queue_timeout2)
|
||||
|
||||
pthread_join(tid1, NULL);
|
||||
|
||||
uc_thread_queue_destroy(&queue, NULL);
|
||||
uc_thread_queue_destroy(&queue, NULL, NULL);
|
||||
|
||||
END_TEST
|
||||
|
||||
@@ -270,7 +271,7 @@ START_TEST (test_thread_queue_tryadd_timeout_0_0)
|
||||
|
||||
fail_if(uc_thread_queue_tryadd(&queue, &timeout, &msg[2].msg) != ETIMEDOUT);
|
||||
|
||||
fail_if(uc_thread_queue_destroy(&queue, NULL) != 0);
|
||||
fail_if(uc_thread_queue_destroy(&queue, NULL, NULL) != 0);
|
||||
|
||||
END_TEST
|
||||
|
||||
@@ -289,7 +290,7 @@ START_TEST (test_thread_queue_tryadd_timeout_0_100)
|
||||
|
||||
fail_if(uc_thread_queue_tryadd(&queue, &timeout, &msg[2].msg) != ETIMEDOUT);
|
||||
|
||||
fail_if(uc_thread_queue_destroy(&queue, NULL) != 0);
|
||||
fail_if(uc_thread_queue_destroy(&queue, NULL, NULL) != 0);
|
||||
|
||||
END_TEST
|
||||
|
||||
@@ -308,7 +309,7 @@ START_TEST (test_thread_queue_tryadd_no_timeout_0_100)
|
||||
|
||||
fail_if(uc_thread_queue_tryadd(&queue, &timeout, &msg[2].msg) != 0);
|
||||
|
||||
fail_if(uc_thread_queue_destroy(&queue, NULL) != 0);
|
||||
fail_if(uc_thread_queue_destroy(&queue, NULL, NULL) != 0);
|
||||
|
||||
END_TEST
|
||||
|
||||
|
||||
Reference in New Issue
Block a user