ObjFW  Diff

Differences From Artifact [dc21f4b704]:

To Artifact [28fcccac40]:


27
28
29
30
31
32
33

34
35
36
37
38
39
40
# include <sched.h>
#endif

#import "OFThread.h"
#import "OFList.h"
#import "OFDate.h"
#import "OFSortedList.h"

#import "OFAutoreleasePool.h"

#ifdef _WIN32
# include <windows.h>
#endif

#import "OFConditionBroadcastFailedException.h"







>







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# include <sched.h>
#endif

#import "OFThread.h"
#import "OFList.h"
#import "OFDate.h"
#import "OFSortedList.h"
#import "OFRunLoop.h"
#import "OFAutoreleasePool.h"

#ifdef _WIN32
# include <windows.h>
#endif

#import "OFConditionBroadcastFailedException.h"
278
279
280
281
282
283
284
285
286
287
288
289
290
291

292
293
294
295
296
297
298
						    selector: _cmd];

	return nil;
}

- (void)handleTermination
{
	@synchronized (timersQueue) {
		/*
		 * Make sure we don't run old timers when the thread is
		 * restarted.
		 */
		[timersQueue removeAllObjects];
	}

}

- (void)start
{
	if (running == OF_THREAD_RUNNING)
		@throw [OFThreadStillRunningException
		    exceptionWithClass: [self class]







<
<
<
|
<
<
<
>







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]
323
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
361
362
363
364
365
				thread: self];

	running = OF_THREAD_NOT_RUNNING;

	return returnValue;
}

- (OFSortedList*)_timersQueue
{
	if (timersQueue == nil) {
		OFSortedList *tmp = [[OFSortedList alloc] init];

		if (!of_atomic_cmpswap_ptr((void**)&timersQueue, nil, tmp))
			[tmp release];
	}




	return [[timersQueue 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];
	[timersQueue release];

	[super dealloc];
}

- copy
{
	return [self retain];







|

|
<
|
<
<
|
>
|
>
>
|


















<







319
320
321
322
323
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
				thread: self];

	running = OF_THREAD_NOT_RUNNING;

	return returnValue;
}

- (OFRunLoop*)runLoop
{
	return [[runLoop retain] autorelease];

}



- (void)_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];