Differences From Artifact [94dbbf6fa0]:
- File
src/OFThread.m
— part of check-in
[0a55edad35]
at
2012-10-26 11:04:41
on branch trunk
— Split OFThread.m into multiple files.
It was time to finally have one file per class. (user: js, size: 6997) [annotate] [blame] [check-ins using]
To Artifact [378318c425]:
- File
src/OFThread.m
— part of check-in
[0639a351db]
at
2012-11-10 00:14:59
on branch trunk
— Remove "object" from OFThread.
Blocks don't allow passing it anymore and without blocks, subclassing is
necessary anyway so that an ivar with the correct type can be added
(instead of id) if required. (user: js, size: 6766) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
66 67 68 69 70 71 72 | /* * Nasty workaround for thread implementations which can't return a * value on join. */ #ifdef OF_HAVE_BLOCKS if (thread->block != NULL) | | | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | /* * Nasty workaround for thread implementations which can't return a * value on join. */ #ifdef OF_HAVE_BLOCKS if (thread->block != NULL) thread->returnValue = [thread->block() retain]; else #endif thread->returnValue = [[thread main] retain]; [thread handleTermination]; thread->running = OF_THREAD_WAITING_FOR_JOIN; |
︙ | ︙ | |||
110 111 112 113 114 115 116 | } + (instancetype)thread { return [[[self alloc] init] autorelease]; } | < < < < < | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | } + (instancetype)thread { return [[[self alloc] init] autorelease]; } #ifdef OF_HAVE_BLOCKS + (instancetype)threadWithBlock: (of_thread_block_t)block { return [[[self alloc] initWithBlock: block] autorelease]; } #endif |
︙ | ︙ | |||
237 238 239 240 241 242 243 | mainThread->thread = of_thread_current(); if (!of_tlskey_set(threadSelfKey, mainThread)) @throw [OFInitializationFailedException exceptionWithClass: self]; } | < < < < < < < < < | 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | mainThread->thread = of_thread_current(); if (!of_tlskey_set(threadSelfKey, mainThread)) @throw [OFInitializationFailedException exceptionWithClass: self]; } #ifdef OF_HAVE_BLOCKS - initWithBlock: (of_thread_block_t)block_ { self = [super init]; @try { block = [block_ copy]; |
︙ | ︙ | |||
271 272 273 274 275 276 277 | [[OFRunLoop currentRunLoop] run]; return nil; } - (void)handleTermination { | | | | 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | [[OFRunLoop currentRunLoop] run]; return nil; } - (void)handleTermination { OFRunLoop *oldRunLoop = runLoop; runLoop = nil; [oldRunLoop release]; } - (void)start { if (running == OF_THREAD_RUNNING) @throw [OFThreadStillRunningException exceptionWithClass: [self class] |
︙ | ︙ | |||
338 339 340 341 342 343 344 | /* * 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); | < | 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | /* * 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]; [runLoop release]; [super dealloc]; } - copy { return [self retain]; } @end |