Overview
Comment: | Fix and optimize @synchronize on Win32. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
362a9430993e88a8d7299339d7e84612 |
User & Date: | js on 2009-06-01 04:02:17 |
Other Links: | manifest | tags |
Context
2009-06-01
| ||
04:08 | Optimize OFMutex on Win32 and add missing -[dealloc]. check-in: ddcee670e4 user: js tags: trunk | |
04:02 | Fix and optimize @synchronize on Win32. check-in: 362a943099 user: js tags: trunk | |
02:08 | Add OFMutex and use it in OFTCPSocket instead of @synchronized. check-in: cca028cedf user: js tags: trunk | |
Changes
Modified src/objc_sync.m from [0a8dcabb44] to [dc3b3466a2].
︙ | ︙ | |||
24 25 26 27 28 29 30 | #ifdef _WIN32 #include <windows.h> #endif #import "OFMacros.h" struct locks_s { | | | | | | | | | | 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 | #ifdef _WIN32 #include <windows.h> #endif #import "OFMacros.h" struct locks_s { id obj; size_t count; size_t recursion; #ifndef _WIN32 pthread_t thread; pthread_mutex_t mutex; #else DWORD thread; CRITICAL_SECTION mutex; #endif }; #ifndef _WIN32 static pthread_mutex_t mutex; #else static CRITICAL_SECTION mutex; #endif static struct locks_s *locks = NULL; static size_t num_locks = 0; #ifndef _WIN32 static OF_INLINE BOOL mutex_new(pthread_mutex_t *m) |
︙ | ︙ | |||
82 83 84 85 86 87 88 | static OF_INLINE pthread_t thread_current() { return pthread_self(); } #else static OF_INLINE BOOL | | > | | > | | > | | > | | | | | | 82 83 84 85 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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | static OF_INLINE pthread_t thread_current() { return pthread_self(); } #else static OF_INLINE BOOL mutex_new(CRITICAL_SECTION *m) { InitializeCriticalSection(m); return YES; } static OF_INLINE BOOL mutex_free(CRITICAL_SECTION *m) { DeleteCriticalSection(m); return YES; } static OF_INLINE BOOL mutex_lock(CRITICAL_SECTION *m) { EnterCriticalSection(m); return YES; } static OF_INLINE BOOL mutex_unlock(CRITICAL_SECTION *m) { LeaveCriticalSection(m); return YES; } static OF_INLINE BOOL thread_is_current(DWORD t) { return (t == GetCurrentThreadId() ? YES : NO); } static OF_INLINE DWORD thread_current() { return GetCurrentThreadId(); } #endif BOOL objc_sync_init() { return (mutex_new(&mutex) ? YES : NO); |
︙ | ︙ |