Differences From Artifact [fe4bfba4ee]:
- File
src/OFThread.m
— part of check-in
[b45a563f2b]
at
2020-12-06 17:49:25
on branch trunk
— Use a single global socket base on MorphOS
MorphOS allows sharing a single socket base between tasks, so having a
per-task socket base is unnecessary. (user: js, size: 10804) [annotate] [blame] [check-ins using] [more...]
To Artifact [7d209d5958]:
- File
src/OFThread.m
— part of check-in
[5b37fbeb82]
at
2020-12-20 21:26:08
on branch trunk
— Return error instead of using errno for threading
errno is problematic for Amiga libraries and is also not thread-safe on
some systems, even though it should. (user: js, size: 10869) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
99 100 101 102 103 104 105 | #ifdef OF_HAVE_THREADS static void callMain(id object) { OFThread *thread = (OFThread *)object; OFString *name; | | | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | #ifdef OF_HAVE_THREADS static void callMain(id object) { OFThread *thread = (OFThread *)object; OFString *name; if (of_tlskey_set(threadSelfKey, thread) != 0) @throw [OFInitializationFailedException exceptionWithClass: thread.class]; #ifndef OF_OBJFW_RUNTIME thread->_pool = objc_autoreleasePoolPush(); #endif |
︙ | ︙ | |||
162 163 164 165 166 167 168 | # endif + (void)initialize { if (self != [OFThread class]) return; | | | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | # endif + (void)initialize { if (self != [OFThread class]) return; if (of_tlskey_new(&threadSelfKey) != 0) @throw [OFInitializationFailedException exceptionWithClass: self]; } + (instancetype)thread { return [[[self alloc] init] autorelease]; |
︙ | ︙ | |||
346 347 348 349 350 351 352 | + (void)of_createMainThread { mainThread = [[OFThread alloc] init]; mainThread->_thread = of_thread_current(); mainThread->_running = OF_THREAD_RUNNING; | | | | 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | + (void)of_createMainThread { mainThread = [[OFThread alloc] init]; mainThread->_thread = of_thread_current(); mainThread->_running = OF_THREAD_RUNNING; if (of_tlskey_set(threadSelfKey, mainThread) != 0) @throw [OFInitializationFailedException exceptionWithClass: self]; } - (instancetype)init { self = [super init]; @try { if (of_thread_attr_init(&_attr) != 0) @throw [OFInitializationFailedException exceptionWithClass: self.class]; } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ | |||
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | [_DNSResolver release]; _DNSResolver = nil; # endif } - (void)start { if (_running == OF_THREAD_RUNNING) @throw [OFThreadStillRunningException exceptionWithThread: self]; if (_running == OF_THREAD_WAITING_FOR_JOIN) { of_thread_detach(_thread); [_returnValue release]; } [self retain]; _running = OF_THREAD_RUNNING; | > > | | < | > > | | | 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | [_DNSResolver release]; _DNSResolver = nil; # endif } - (void)start { int error; if (_running == OF_THREAD_RUNNING) @throw [OFThreadStillRunningException exceptionWithThread: self]; if (_running == OF_THREAD_WAITING_FOR_JOIN) { of_thread_detach(_thread); [_returnValue release]; } [self retain]; _running = OF_THREAD_RUNNING; if ((error = of_thread_new(&_thread, [_name cStringWithEncoding: [OFLocale encoding]], callMain, self, &_attr)) != 0) { [self release]; @throw [OFThreadStartFailedException exceptionWithThread: self errNo: error]; } } - (id)join { int error; if (_running == OF_THREAD_NOT_RUNNING) @throw [OFThreadJoinFailedException exceptionWithThread: self errNo: EINVAL]; if ((error = of_thread_join(_thread)) != 0) @throw [OFThreadJoinFailedException exceptionWithThread: self errNo: error]; _running = OF_THREAD_NOT_RUNNING; return _returnValue; } - (id)copy |
︙ | ︙ |