Differences From Artifact [fd76b79d25]:
- File src/OFThread.m — part of check-in [b7142607c2] at 2011-03-25 15:48:50 on branch trunk — Pass the condition for condition exceptions. (user: js, size: 8562) [annotate] [blame] [check-ins using]
To Artifact [e52975424c]:
- File
src/OFThread.m
— part of check-in
[59e52af26d]
at
2011-07-17 01:55:16
on branch 0.5
— Define __NO_EXT_QNX in files using unistd.h or fcntl.h.
Without this, the headers try to declare functions that use __block as
an argument name and thus fail to compile when using -fblocks. (user: js, size: 9210) [annotate] [blame] [check-ins using]
| ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | + + + + + + | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #define __NO_EXT_QNX #ifndef _WIN32 # include <unistd.h> # include <sched.h> #else # include <windows.h> #endif #if defined(OF_GNU_RUNTIME) || defined(OF_OLD_GNU_RUNTIME) # import <objc/thr.h> #endif #import "OFThread.h" #import "OFList.h" #import "OFDate.h" #import "OFAutoreleasePool.h" #import "OFConditionBroadcastFailedException.h" |
| ︙ | |||
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | + + + + + + + + |
static OFList *tlskeys;
static of_tlskey_t thread_self;
static id
call_main(id obj)
{
#if defined(OF_GNU_RUNTIME) || defined(OF_OLD_GNU_RUNTIME)
objc_thread_add();
#endif
if (!of_tlskey_set(thread_self, obj))
@throw [OFInitializationFailedException
newWithClass: [obj class]];
/*
* Nasty workaround for thread implementations which can't return a
* value on join.
*/
((OFThread*)obj)->retval = [[obj main] retain];
[obj handleTermination];
((OFThread*)obj)->running = OF_THREAD_WAITING_FOR_JOIN;
[OFTLSKey callAllDestructors];
[OFAutoreleasePool releaseAll];
[obj release];
#if defined(OF_GNU_RUNTIME) || defined(OF_OLD_GNU_RUNTIME)
objc_thread_remove();
#endif
return 0;
}
@implementation OFThread
+ (void)initialize
{
|
| ︙ | |||
204 205 206 207 208 209 210 211 212 213 214 215 216 217 | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | + + + + |
thread->running = OF_THREAD_WAITING_FOR_JOIN;
}
[OFTLSKey callAllDestructors];
[OFAutoreleasePool releaseAll];
[thread release];
#if defined(OF_GNU_RUNTIME) || defined(OF_OLD_GNU_RUNTIME)
objc_thread_remove();
#endif
of_thread_exit();
}
- initWithObject: (id)obj
{
self = [super init];
|
| ︙ | |||
239 240 241 242 243 244 245 246 247 248 249 250 251 252 | 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | + + + + + |
}
- (void)start
{
if (running == OF_THREAD_RUNNING)
@throw [OFThreadStillRunningException newWithClass: isa
thread: self];
if (running == OF_THREAD_WAITING_FOR_JOIN) {
of_thread_detach(thread);
[retval release];
}
[self retain];
if (!of_thread_new(&thread, call_main, self)) {
[self release];
@throw [OFThreadStartFailedException newWithClass: isa
thread: self];
|
| ︙ | |||
268 269 270 271 272 273 274 275 276 277 278 279 280 281 | 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | + + + + + + + |
- (void)dealloc
{
if (running == OF_THREAD_RUNNING)
@throw [OFThreadStillRunningException newWithClass: isa
thread: self];
/*
* 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);
[object release];
[retval release];
[super dealloc];
}
@end
|
| ︙ |