@@ -17,12 +17,14 @@ #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 @@ -195,10 +197,18 @@ 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_ @@ -217,10 +227,11 @@ object1 = [object1_ retain]; object2 = [object2_ retain]; arguments = arguments_; repeats = repeats_; isValid = YES; + condition = [[OFCondition alloc] init]; } @catch (id e) { [self release]; @throw e; } @@ -307,10 +318,11 @@ [object1 release]; [object2 release]; #ifdef OF_HAVE_BLOCKS [block release]; #endif + [condition release]; [super dealloc]; } - (of_comparison_result_t)compare: (id )object_ @@ -352,10 +364,14 @@ } #ifdef OF_HAVE_BLOCKS } #endif + [condition lock]; + [condition signal]; + [condition unlock]; + if (repeats) { OFDate *old = fireDate; fireDate = [[OFDate alloc] initWithTimeIntervalSinceNow: interval]; [old release]; @@ -382,6 +398,13 @@ - (BOOL)isValid { return isValid; } + +- (void)waitUntilDone +{ + [condition lock]; + [condition wait]; + [condition unlock]; +} @end