blob: 7313784b19c6a54d54fa76dfd35112220a1f8973 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include <al/lib.h>
#include <nnwt/common.h>
#include <nnwt/thread.h>
static struct nn_mutex mutex;
static struct nn_cond cond;
static struct nn_thread thread;
static nn_thread_result NNWT_THREADCALL test_thread(void *userdata)
{
(void)userdata;
nn_mutex_lock(&mutex);
nn_cond_wait(&cond, &mutex);
nn_mutex_unlock(&mutex);
return 0;
}
s32 main(void)
{
if (!nn_common_init(NULL)) return EXIT_FAILURE;
nn_mutex_init(&mutex);
nn_cond_init(&cond);
nn_thread_create(&thread, test_thread, NULL);
nn_thread_sleep(NNWT_TS_FROM_USEC(1000000));
nn_mutex_lock(&mutex);
nn_cond_signal(&cond);
// cond_wait() won't return until we unlock here.
nn_mutex_unlock(&mutex);
nn_thread_join(&thread);
nn_common_close();
return EXIT_SUCCESS;
}
|