Differences From Artifact [076ba07ad1]:
- File
src/OFThread.m
— part of check-in
[a3639589d3]
at
2013-06-30 18:30:12
on branch trunk
— Rename -[initWithBlock:].
It is now called -[initWithThreadBlock:] in order to prevent method
signature conflicts.This also fixes a missing release for the thread block. (user: js, size: 7768) [annotate] [blame] [check-ins using]
To Artifact [c78e4c4d29]:
- File src/OFThread.m — part of check-in [1eaf875a88] at 2013-07-28 21:07:59 on branch trunk — Replace OFTLSKey w/ +[OFThread threadDictionary]. (user: js, size: 7576) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
37 38 39 40 41 42 43 | # include <kernel/OS.h> #endif #import "OFRunLoop.h" #import "OFThread.h" #import "OFList.h" #import "OFDate.h" | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | # include <kernel/OS.h> #endif #import "OFRunLoop.h" #import "OFThread.h" #import "OFList.h" #import "OFDate.h" #import "OFDictionary.h" #import "OFAutoreleasePool.h" #ifdef _WIN32 # include <windows.h> #endif #import "OFInitializationFailedException.h" |
︙ | ︙ | |||
91 92 93 94 95 96 97 | # endif thread->_returnValue = [[thread main] retain]; [thread handleTermination]; thread->_running = OF_THREAD_WAITING_FOR_JOIN; | < | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | # endif thread->_returnValue = [[thread main] retain]; [thread handleTermination]; thread->_running = OF_THREAD_WAITING_FOR_JOIN; # ifdef OF_OBJFW_RUNTIME /* * As the values returned by objc_autoreleasePoolPush() in the ObjFW * runtime are not actually pointers, but sequential numbers, 0 means * we pop everything. */ objc_autoreleasePoolPop(0); |
︙ | ︙ | |||
149 150 151 152 153 154 155 | # ifdef OF_HAVE_BLOCKS + (instancetype)threadWithThreadBlock: (of_thread_block_t)threadBlock { return [[[self alloc] initWithThreadBlock: threadBlock] autorelease]; } # endif | < < < < < < < < < < < < < < < < < | > > > > > > > > > > | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | # ifdef OF_HAVE_BLOCKS + (instancetype)threadWithThreadBlock: (of_thread_block_t)threadBlock { return [[[self alloc] initWithThreadBlock: threadBlock] autorelease]; } # endif + (OFThread*)currentThread { return of_tlskey_get(threadSelfKey); } + (OFThread*)mainThread { return mainThread; } + (OFMutableDictionary*)threadDictionary { OFThread *thread = of_tlskey_get(threadSelfKey); if (thread->_threadDictionary == nil) thread->_threadDictionary = [[OFMutableDictionary alloc] init]; return thread->_threadDictionary; } #endif + (void)sleepForTimeInterval: (double)seconds { if (seconds < 0) @throw [OFOutOfRangeException exception]; |
︙ | ︙ | |||
238 239 240 241 242 243 244 | thread->_returnValue = [object retain]; [thread handleTermination]; thread->_running = OF_THREAD_WAITING_FOR_JOIN; } | < | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | thread->_returnValue = [object retain]; [thread handleTermination]; thread->_running = OF_THREAD_WAITING_FOR_JOIN; } # ifdef OF_OBJFW_RUNTIME /* * As the values returned by objc_autoreleasePoolPush() in the ObjFW * runtime are not actually pointers, but sequential numbers, 0 means * we pop everything. */ objc_autoreleasePoolPop(0); |
︙ | ︙ | |||
291 292 293 294 295 296 297 298 299 300 301 302 303 304 | } - (void)handleTermination { OFRunLoop *oldRunLoop = _runLoop; _runLoop = nil; [oldRunLoop release]; } - (void)start { if (_running == OF_THREAD_RUNNING) @throw [OFThreadStillRunningException exceptionWithThread: self]; | > > > | 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | } - (void)handleTermination { OFRunLoop *oldRunLoop = _runLoop; _runLoop = nil; [oldRunLoop release]; [_threadDictionary release]; _threadDictionary = nil; } - (void)start { if (_running == OF_THREAD_RUNNING) @throw [OFThreadStillRunningException exceptionWithThread: self]; |
︙ | ︙ | |||
377 378 379 380 381 382 383 | * We should not be running anymore, but call detach in order to free * the resources. */ if (_running == OF_THREAD_WAITING_FOR_JOIN) of_thread_detach(_thread); [_returnValue release]; | < | 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | * We should not be running anymore, but call detach in order to free * the resources. */ if (_running == OF_THREAD_WAITING_FOR_JOIN) of_thread_detach(_thread); [_returnValue release]; # ifdef OF_HAVE_BLOCKS [_threadBlock release]; # endif [super dealloc]; } #else |
︙ | ︙ |