Initial import to Tizen
[profile/ivi/sphinxbase.git] / test / unit / test_thread / test_event.c
1 #include <stdio.h>
2 #include <sbthread.h>
3 #include <err.h>
4
5 int
6 worker_main(sbthread_t *th)
7 {
8         sbevent_t *cond;
9
10         cond = sbthread_arg(th);
11
12         /* Get the first signal. */
13         sbevent_wait(cond, -1, -1);
14         E_INFO("Got signal\n");
15
16         /* Now wait a while and exit. */
17         sbevent_wait(cond, 1, 500*1000*1000);
18         return 0;
19 }
20
21 int
22 main(int argc, char *argv[])
23 {
24         sbthread_t *worker;
25         sbevent_t *cond;
26
27         cond = sbevent_init();
28         worker = sbthread_start(NULL, worker_main, cond);
29
30         E_INFO("Signalling condition\n");
31         sbevent_signal(cond);
32
33         E_INFO("Waiting (about 1.5 sec) for thread termination\n");
34         sbthread_free(worker);
35         sbevent_free(cond);
36         return 0;
37 }