ae2f_docs
thrdjoin.c
1#include <ae2f/Sys/Thrd.h>
2#include <stdio.h>
3#include <time.h>
4
5ae2f_SysThrdRes_t AThreadNotifier(ae2f_SysThrdPrm_t prm) {
6 struct timespec req, rem;
7 register int done;
8
9 req.tv_sec = 0;
10 req.tv_nsec = 4000;
11
12 printf("Thread child is starting\n");
13
14 _ae2f_SysThrdSleep_imp(done, &req, &rem);
15
16 printf("Thread child is ending\n");
18}
19
20int main() {
21 register ae2f_eSysThrd_t ret_stat = 0;
22 ae2f_SysThrd ret_thrd0, ret_thrd1;
23
24 ae2f_SysThrdRes_t ret_rtn;
25
26 ret_rtn = 0;
27
28 puts("Thread main is starting");
29
30#if 1
32 ret_stat
33 , ret_thrd0
34 , AThreadNotifier
35 , NULL
36 , 1024 * 512
37 );
38
40 ret_stat
41 , ret_thrd1
42 , AThreadNotifier
43 , NULL
44 , 1024 * 512
45 );
46#else
47#endif
48
49 puts("Thread main has made a thread");
50 printf("ret_stat: %d\n", ret_stat);
51
52
54 ret_stat
55 , ret_rtn
56 , ret_thrd0
57 );
58
59 printf(
60 "Thread main joined %d with retval %d\n"
61 , (ret_thrd0).m_id, ret_rtn);
62
64 ret_stat
65 , ret_rtn
66 , ret_thrd1
67 );
68
69 printf(
70 "Thread main joined %d with retval %d\n"
71 , (ret_thrd1).m_id, ret_rtn);
72
73
74
75 puts("Thread main is ending");
76
77 return 0;
78}
#define ae2f_reinterpret_cast(t, v)
Definition Cast.h:52
#define _ae2f_SysThrdJoin_imp(ret_stat, ret_rtn, ref_thrd)
Definition Thrd.auto.h:333
#define _ae2f_SysThrdSleep_imp(ret_stat, prm_req, prm_rem)
Definition Thrd.auto.h:361
#define _ae2f_SysThrdMk_imp(ret_stat, ret_thrd, prm_func, prm_arg, prm_stcksz_unused)
Definition Thrd.auto.h:297
_ae2f_SysThrdRes_t ae2f_SysThrdRes_t
Return type for thread.
Definition Thrd.h:14
_ae2f_SysThrdPrm_t ae2f_SysThrdPrm_t
Parameters for thread.
Definition Thrd.h:18