Differences From Artifact [c4677d1bcf]:
- File
src/threading.h
— part of check-in
[13ee56edf3]
at
2014-06-21 21:43:43
on branch trunk
— Move all macros from OFObject.h to macros.h
This means that OFObject.h imports macros.h now, making it unnecessary
to manually import macros.h in almost every file. And while at it, also
import autorelease.h in OFObject.h, so that this doesn't need to be
manually imported in almost every file as well. (user: js, size: 12416) [annotate] [blame] [check-ins using]
To Artifact [90da9579d7]:
- File src/threading.h — part of check-in [ff23684e9d] at 2014-07-16 15:16:27 on branch trunk — Coding style (user: js, size: 12459) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
86 87 88 89 90 91 92 | # error of_thread_current not implemented! #endif static OF_INLINE bool of_thread_new(of_thread_t *thread, id (*function)(id), id data) { #if defined(OF_HAVE_PTHREADS) | | | | | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | # error of_thread_current not implemented! #endif static OF_INLINE bool of_thread_new(of_thread_t *thread, id (*function)(id), id data) { #if defined(OF_HAVE_PTHREADS) return (pthread_create(thread, NULL, (void*(*)(void*))function, (__bridge void*)data) == 0); #elif defined(_WIN32) *thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)function, (__bridge void*)data, 0, NULL); return (thread != NULL); #else # error of_thread_new not implemented! #endif } static OF_INLINE bool of_thread_join(of_thread_t thread) { #if defined(OF_HAVE_PTHREADS) void *ret; if (pthread_join(thread, &ret) != 0) return false; # ifdef PTHREAD_CANCELED return (ret != PTHREAD_CANCELED); # else return true; # endif |
︙ | ︙ | |||
226 227 228 229 230 231 232 | #endif } static OF_INLINE bool of_mutex_unlock(of_mutex_t *mutex) { #if defined(OF_HAVE_PTHREADS) | | | | 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | #endif } static OF_INLINE bool of_mutex_unlock(of_mutex_t *mutex) { #if defined(OF_HAVE_PTHREADS) return (pthread_mutex_unlock(mutex) == 0); #elif defined(_WIN32) LeaveCriticalSection(mutex); return true; #else # error of_mutex_unlock not implemented! #endif } static OF_INLINE bool of_condition_new(of_condition_t *condition) { #if defined(OF_HAVE_PTHREADS) return (pthread_cond_init(condition, NULL) == 0); #elif defined(_WIN32) condition->count = 0; if ((condition->event = CreateEvent(NULL, FALSE, 0, NULL)) == NULL) return false; return true; |
︙ | ︙ | |||
490 491 492 493 494 495 496 | #ifdef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES static OF_INLINE bool of_rmutex_new(of_mutex_t *mutex) { pthread_mutexattr_t attr; | | | | | | 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 | #ifdef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES static OF_INLINE bool of_rmutex_new(of_mutex_t *mutex) { pthread_mutexattr_t attr; if (pthread_mutexattr_init(&attr) != 0) return false; if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0) return false; if (pthread_mutex_init(mutex, &attr) != 0) return false; if (pthread_mutexattr_destroy(&attr) != 0) return false; return true; } # define of_rmutex_lock of_mutex_lock # define of_rmutex_trylock of_mutex_trylock |
︙ | ︙ |