22 #include <gtest/gtest.h> 26 # include <pthread_np.h> 28 #include <core/threading/wait_condition.h> 65 pthread_t threads[num_threads];
67 for (uint i = 0; i < num_threads; i++) {
69 params[i]->
cond = cond;
70 pthread_create(&threads[i], NULL, thread_func, params[i]);
75 for (uint i = 0; i < num_threads; i++) {
76 pthread_cancel(threads[i]);
78 ASSERT_NE(-1, clock_gettime(CLOCK_REALTIME, &ts));
81 ASSERT_EQ(0, pthread_timedjoin_np(threads[i], NULL, &ts));
88 const uint num_threads;
92 start_waiter_thread(
void *args)
100 start_abstimed_waiter_thread(
void *args)
104 EXPECT_NE(-1, clock_gettime(CLOCK_REALTIME, &ts));
111 start_reltimed_waiter_thread(
void *args)
120 start_test(start_waiter_thread);
125 start_test(start_abstimed_waiter_thread);
130 start_test(start_reltimed_waiter_thread);
Test class for WaitConditions This class tets basic functionality of WaitConditions,...
Wait until a given condition holds.
bool reltimed_wait(unsigned int sec, unsigned int nanosec)
Wait with relative timeout.
Fawkes library namespace.
WaitCondition * cond
The thread's wait condition.
The parameters passed to the threads.
void start_test(void *(*thread_func)(void *))
Start threads with the given function, cancel the threads and assert they have terminated.
void wait()
Wait for the condition forever.
bool abstimed_wait(long int sec, long int nanosec)
Wait with absolute timeout.