Overview
Comment: | Move of_once() to threading.m |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
3f31bd034daf3b1b87582474e647e709 |
User & Date: | js on 2016-04-18 21:40:01 |
Other Links: | manifest | tags |
Context
2016-04-18
| ||
21:48 | Add of_thread_yield() check-in: fa79bc173e user: js tags: trunk | |
21:40 | Move of_once() to threading.m check-in: 3f31bd034d user: js tags: trunk | |
17:28 | OFCondition: Improve documentation check-in: dc52529ee7 user: js tags: trunk | |
Changes
Modified src/threading.h from [ab485ea64f] to [b27d0410b9].
︙ | ︙ | |||
49 50 51 52 53 54 55 | typedef HANDLE of_thread_t; typedef DWORD of_tlskey_t; typedef CRITICAL_SECTION of_mutex_t; typedef struct { HANDLE event; int count; } of_condition_t; | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | typedef HANDLE of_thread_t; typedef DWORD of_tlskey_t; typedef CRITICAL_SECTION of_mutex_t; typedef struct { HANDLE event; int count; } of_condition_t; typedef volatile int of_once_t; # define OF_ONCE_INIT 0 #else # error No threads available! #endif #if defined(OF_HAVE_ATOMIC_OPS) # import "atomic.h" |
︙ | ︙ |
Modified src/threading.m from [cdd5b61733] to [acfd94987f].
︙ | ︙ | |||
21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #if defined(OF_HAVE_PTHREADS) # include "threading_pthread.m" #elif defined(OF_WINDOWS) # include "threading_winapi.m" #else # error No threads available! #endif #if !defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) && !defined(OF_WINDOWS) bool of_rmutex_new(of_rmutex_t *rmutex) { if (!of_mutex_new(&rmutex->mutex)) return false; | > > > > > > > > > > > > > > > > > > > > | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #if defined(OF_HAVE_PTHREADS) # include "threading_pthread.m" #elif defined(OF_WINDOWS) # include "threading_winapi.m" #else # error No threads available! #endif #ifndef OF_HAVE_PTHREADS void of_once(of_once_t *control, void (*func)(void)) { if (of_atomic_int_cmpswap(control, 0, 1)) { func(); of_atomic_int_inc(control); } else { while (*control == 1) # if defined(HAVE_SCHED_YIELD) sched_yield(); # elif defined(OF_WINDOWS) Sleep(0); # else ; # endif } } #endif #if !defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) && !defined(OF_WINDOWS) bool of_rmutex_new(of_rmutex_t *rmutex) { if (!of_mutex_new(&rmutex->mutex)) return false; |
︙ | ︙ |
Modified src/threading_winapi.m from [7b696c0768] to [9dd35eedd7].
︙ | ︙ | |||
86 87 88 89 90 91 92 | } void of_thread_set_name(of_thread_t thread, const char *name) { } | < < < < < < < < < < < < < < < | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | } void of_thread_set_name(of_thread_t thread, const char *name) { } bool of_mutex_new(of_mutex_t *mutex) { InitializeCriticalSection(mutex); return true; } |
︙ | ︙ |