︙ | | |
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
-
+
|
@throw [OFInitializationFailedException
exceptionWithClass: [thread class]];
thread->_pool = objc_autoreleasePoolPush();
/*
* Nasty workaround for thread implementations which can't return a
* value on join.
* pointer on join.
*/
# ifdef OF_HAVE_BLOCKS
if (thread->_threadBlock != NULL)
thread->_returnValue = [thread->_threadBlock() retain];
else
# endif
thread->_returnValue = [[thread main] retain];
|
︙ | | |
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
|
mainThread = [[OFThread alloc] init];
mainThread->_thread = of_thread_current();
if (!of_tlskey_set(threadSelfKey, mainThread))
@throw [OFInitializationFailedException
exceptionWithClass: self];
}
- init
{
self = [super init];
@try {
if (!of_thread_attr_init(&_attr))
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
# ifdef OF_HAVE_BLOCKS
- initWithThreadBlock: (of_thread_block_t)threadBlock
{
self = [super init];
self = [self init];
@try {
_threadBlock = [threadBlock copy];
} @catch (id e) {
[self release];
@throw e;
}
|
︙ | | |
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
|
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
-
+
|
[_returnValue release];
}
[self retain];
_running = OF_THREAD_RUNNING;
if (!of_thread_new(&_thread, callMain, self)) {
if (!of_thread_new(&_thread, callMain, self, &_attr)) {
[self release];
@throw [OFThreadStartFailedException exceptionWithThread: self];
}
if (_name != nil)
of_thread_set_name(_thread, [_name UTF8String]);
else
|
︙ | | |
366
367
368
369
370
371
372
373
374
375
376
377
378
379
|
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
if (_name != nil)
of_thread_set_name(_thread, [_name UTF8String]);
else
of_thread_set_name(_thread,
class_getName([self class]));
}
}
- (float)priority
{
return _attr.priority;
}
- (void)setPriority: (float)priority
{
if (_running == OF_THREAD_RUNNING)
@throw [OFThreadStillRunningException
exceptionWithThread: self];
_attr.priority = priority;
}
- (size_t)stackSize
{
return _attr.stackSize;
}
- (void)setStackSize: (size_t)stackSize
{
if (_running == OF_THREAD_RUNNING)
@throw [OFThreadStillRunningException
exceptionWithThread: self];
_attr.stackSize = stackSize;
}
- (void)dealloc
{
if (_running == OF_THREAD_RUNNING)
@throw [OFThreadStillRunningException
exceptionWithThread: self];
|
︙ | | |