236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
mainThread->thread = of_thread_current();
if (!of_tlskey_set(threadSelfKey, mainThread))
@throw [OFInitializationFailedException
exceptionWithClass: self];
}
- initWithObject: (id)object_
{
self = [super init];
object = [object_ retain];
return self;
}
#ifdef OF_HAVE_BLOCKS
- initWithBlock: (of_thread_block_t)block_
{
return [self initWithObject: nil
block: block_];
}
- initWithObject: (id)object_
block: (of_thread_block_t)block_
{
self = [super init];
@try {
object = [object_ retain];
block = [block_ copy];
} @catch (id e) {
[self release];
@throw e;
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
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
|
mainThread->thread = of_thread_current();
if (!of_tlskey_set(threadSelfKey, mainThread))
@throw [OFInitializationFailedException
exceptionWithClass: self];
}
- init
{
self = [super init];
@try {
runLoop = [[OFRunLoop alloc] init];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithObject: (id)object_
{
self = [self init];
object = [object_ retain];
return self;
}
#ifdef OF_HAVE_BLOCKS
- initWithBlock: (of_thread_block_t)block_
{
return [self initWithObject: nil
block: block_];
}
- initWithObject: (id)object_
block: (of_thread_block_t)block_
{
self = [self init];
@try {
object = [object_ retain];
block = [block_ copy];
} @catch (id e) {
[self release];
@throw e;
|
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
selector: _cmd];
return nil;
}
- (void)handleTermination
{
[runLoop release];
runLoop = nil;
}
- (void)start
{
if (running == OF_THREAD_RUNNING)
@throw [OFThreadStillRunningException
exceptionWithClass: [self class]
|
|
|
>
|
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
selector: _cmd];
return nil;
}
- (void)handleTermination
{
OFRunLoop *old = runLoop;
runLoop = [[OFRunLoop alloc] init];
[old release];
}
- (void)start
{
if (running == OF_THREAD_RUNNING)
@throw [OFThreadStillRunningException
exceptionWithClass: [self class]
|
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
}
- (OFRunLoop*)runLoop
{
return [[runLoop retain] autorelease];
}
- (void)OF_setRunLoop: (OFRunLoop*)runLoop_
{
OFRunLoop *old = runLoop;
runLoop = [runLoop_ retain];
[old release];
}
- (void)dealloc
{
if (running == OF_THREAD_RUNNING)
@throw [OFThreadStillRunningException
exceptionWithClass: [self class]
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];
[returnValue release];
[super dealloc];
}
- copy
{
return [self retain];
|
<
<
<
<
<
<
<
>
|
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
}
- (OFRunLoop*)runLoop
{
return [[runLoop retain] autorelease];
}
- (void)dealloc
{
if (running == OF_THREAD_RUNNING)
@throw [OFThreadStillRunningException
exceptionWithClass: [self class]
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];
[returnValue release];
[runLoop release];
[super dealloc];
}
- copy
{
return [self retain];
|