ObjFW  Diff

Differences From Artifact [925c86fe94]:

To Artifact [71481b674a]:


15
16
17
18
19
20
21

22
23

24
25
26
27
28
29
30
 */

#include "config.h"

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


#import "OFInvalidArgumentException.h"


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

@implementation OFTimer
+ scheduledTimerWithTimeInterval: (double)interval
			  target: (id)target







>


>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 */

#include "config.h"

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

#import "OFInvalidArgumentException.h"
#import "OFNotImplementedException.h"

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

@implementation OFTimer
+ scheduledTimerWithTimeInterval: (double)interval
			  target: (id)target
193
194
195
196
197
198
199








200
201
202
203
204
205
206

	[timer retain];
	objc_autoreleasePoolPop(pool);

	return [timer autorelease];
}
#endif









- OF_initWithFireDate: (OFDate*)fireDate_
	     interval: (double)interval_
	       target: (id)target_
	     selector: (SEL)selector_
	       object: (id)object1_
	       object: (id)object2_







>
>
>
>
>
>
>
>







195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216

	[timer retain];
	objc_autoreleasePoolPop(pool);

	return [timer autorelease];
}
#endif

- init
{
	Class c = [self class];
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- OF_initWithFireDate: (OFDate*)fireDate_
	     interval: (double)interval_
	       target: (id)target_
	     selector: (SEL)selector_
	       object: (id)object1_
	       object: (id)object2_
215
216
217
218
219
220
221

222
223
224
225
226
227
228
		target = [target_ retain];
		selector = selector_;
		object1 = [object1_ retain];
		object2 = [object2_ retain];
		arguments = arguments_;
		repeats = repeats_;
		isValid = YES;

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

	return self;
}







>







225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
		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;
}
305
306
307
308
309
310
311

312
313
314
315
316
317
318
	[fireDate release];
	[target release];
	[object1 release];
	[object2 release];
#ifdef OF_HAVE_BLOCKS
	[block release];
#endif


	[super dealloc];
}

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







>







316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
	[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;
350
351
352
353
354
355
356




357
358
359
360
361
362
363
				     withObject: object2];
			break;
		}
#ifdef OF_HAVE_BLOCKS
	}
#endif





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

		[[OFRunLoop currentRunLoop] addTimer: self];







>
>
>
>







362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
				     withObject: object2];
			break;
		}
#ifdef OF_HAVE_BLOCKS
	}
#endif

	[condition lock];
	[condition signal];
	[condition unlock];

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

		[[OFRunLoop currentRunLoop] addTimer: self];
380
381
382
383
384
385
386







387
	isValid = NO;
}

- (BOOL)isValid
{
	return isValid;
}







@end







>
>
>
>
>
>
>

396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
	isValid = NO;
}

- (BOOL)isValid
{
	return isValid;
}

- (void)waitUntilDone
{
	[condition lock];
	[condition wait];
	[condition unlock];
}
@end