| 34 | } |
| 35 | |
| 36 | int cbm_thread_create(cbm_thread_t *t, size_t stack_size, void *(*fn)(void *), void *arg) { |
| 37 | if (stack_size == 0) { |
| 38 | stack_size = CBM_DEFAULT_STACK_SIZE; |
| 39 | } |
| 40 | win_thread_arg_t *a = (win_thread_arg_t *)malloc(sizeof(win_thread_arg_t)); |
| 41 | if (!a) { |
| 42 | return CBM_NOT_FOUND; |
| 43 | } |
| 44 | a->fn = fn; |
| 45 | a->arg = arg; |
| 46 | t->handle = CreateThread(NULL, stack_size, win_thread_wrapper, a, 0, NULL); |
| 47 | if (!t->handle) { |
| 48 | free(a); |
| 49 | return CBM_NOT_FOUND; |
| 50 | } |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | int cbm_thread_join(cbm_thread_t *t) { |
| 55 | if (WaitForSingleObject(t->handle, INFINITE) != WAIT_OBJECT_0) { |
no outgoing calls