ObjFW  Diff

Differences From Artifact [301033f339]:

To Artifact [1f8783cad4]:


19
20
21
22
23
24
25

26

27
28
29
30
31
32
33
#include <stdlib.h>

#include <assert.h>

#import "OFTimer.h"
#import "OFDate.h"
#import "OFRunLoop.h"

#import "OFCondition.h"


#import "OFInvalidArgumentException.h"

#import "autorelease.h"
#import "macros.h"

@implementation OFTimer







>
|
>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdlib.h>

#include <assert.h>

#import "OFTimer.h"
#import "OFDate.h"
#import "OFRunLoop.h"
#ifdef OF_THREADS
# import "OFCondition.h"
#endif

#import "OFInvalidArgumentException.h"

#import "autorelease.h"
#import "macros.h"

@implementation OFTimer
231
232
233
234
235
236
237

238

239
240
241
242
243
244
245
		target = [target_ retain];
		selector = selector_;
		object1 = [object1_ retain];
		object2 = [object2_ retain];
		arguments = arguments_;
		repeats = repeats_;
		isValid = YES;

		condition = [[OFCondition alloc] init];

	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}







>

>







233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
		target = [target_ retain];
		selector = selector_;
		object1 = [object1_ retain];
		object2 = [object2_ retain];
		arguments = arguments_;
		repeats = repeats_;
		isValid = YES;
#ifdef OF_THREADS
		condition = [[OFCondition alloc] init];
#endif
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}
305
306
307
308
309
310
311

312

313
314
315
316
317
318
319

	@try {
		fireDate = [fireDate_ retain];
		interval = interval_;
		repeats = repeats_;
		block = [block_ copy];
		isValid = YES;

		condition = [[OFCondition alloc] init];

	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}







>

>







309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325

	@try {
		fireDate = [fireDate_ retain];
		interval = interval_;
		repeats = repeats_;
		block = [block_ copy];
		isValid = YES;
# ifdef OF_THREADS
		condition = [[OFCondition alloc] init];
# endif
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}
330
331
332
333
334
335
336

337

338
339
340
341
342
343
344
	[fireDate release];
	[target release];
	[object1 release];
	[object2 release];
#ifdef OF_HAVE_BLOCKS
	[block release];
#endif

	[condition release];


	[super dealloc];
}

- (of_comparison_result_t)compare: (id <OFComparing>)object_
{
	OFTimer *otherTimer;







>

>







336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
	[fireDate release];
	[target release];
	[object1 release];
	[object2 release];
#ifdef OF_HAVE_BLOCKS
	[block release];
#endif
#ifdef OF_THREADS
	[condition release];
#endif

	[super dealloc];
}

- (of_comparison_result_t)compare: (id <OFComparing>)object_
{
	OFTimer *otherTimer;
376
377
378
379
380
381
382

383
384
385
386
387
388
389

390
391
392
393
394
395
396
				     withObject: object2];
			break;
		}
#ifdef OF_HAVE_BLOCKS
	}
#endif


	[condition lock];
	@try {
		done = YES;
		[condition signal];
	} @finally {
		[condition unlock];
	}


	if (repeats && isValid) {
		OFDate *old = fireDate;
		fireDate = [[OFDate alloc]
		    initWithTimeIntervalSinceNow: interval];
		[old release];








>







>







384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
				     withObject: object2];
			break;
		}
#ifdef OF_HAVE_BLOCKS
	}
#endif

#ifdef OF_THREADS
	[condition lock];
	@try {
		done = YES;
		[condition signal];
	} @finally {
		[condition unlock];
	}
#endif

	if (repeats && isValid) {
		OFDate *old = fireDate;
		fireDate = [[OFDate alloc]
		    initWithTimeIntervalSinceNow: interval];
		[old release];

434
435
436
437
438
439
440

441
442
443
444
445
446
447
448
449
450
451
452
453
454

455
456
457
458
459
460
}

- (BOOL)isValid
{
	return isValid;
}


- (void)waitUntilDone
{
	[condition lock];
	@try {
		if (done) {
			done = NO;
			return;
		}

		[condition wait];
	} @finally {
		[condition unlock];
	}
}


- (void)OF_setInRunLoop: (OFRunLoop*)inRunLoop_
{
	OF_SETTER(inRunLoop, inRunLoop_, YES, 0)
}
@end







>














>






444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
}

- (BOOL)isValid
{
	return isValid;
}

#ifdef OF_THREADS
- (void)waitUntilDone
{
	[condition lock];
	@try {
		if (done) {
			done = NO;
			return;
		}

		[condition wait];
	} @finally {
		[condition unlock];
	}
}
#endif

- (void)OF_setInRunLoop: (OFRunLoop*)inRunLoop_
{
	OF_SETTER(inRunLoop, inRunLoop_, YES, 0)
}
@end