add startup and shutdown methods

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/performance/trunk@38844 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2015-07-28 20:08:10 +00:00
parent d2d36aaa35
commit e2d66ee254
2 changed files with 22 additions and 0 deletions

View file

@ -47,6 +47,16 @@ typedef unsigned int NSUInteger;
* the date is nil or is in the past).
*/
- (void) terminate: (NSDate*)when;
/** Called when the thread is shut down (immediately before exit).<br />
* Does nothing, provided for subclasses to override.
*/
- (void) shutdown;
/** Called when the thread is started up (before the run loop starts).<br />
* Does nothing, provided for subclasses to override.
*/
- (void) startup;
@end
/** This class provides a thread pool for performing methods which need to

View file

@ -62,6 +62,7 @@ static NSRecursiveLock *classLock = nil;
- (void) _finish: (NSTimer*)t
{
_timer = nil;
[self shutdown];
[NSThread exit];
}
@ -72,6 +73,7 @@ static NSRecursiveLock *classLock = nil;
NSDate *when = [NSDate distantFuture];
NSTimeInterval delay = [when timeIntervalSinceNow];
[self startup];
_timer = [NSTimer scheduledTimerWithTimeInterval: delay
target: self
selector: @selector(_finish:)
@ -104,6 +106,16 @@ static NSRecursiveLock *classLock = nil;
}
#endif
- (void) shutdown
{
return;
}
- (void) startup
{
return;
}
/* End execution of the thread by the specified date.
*/
- (void) terminate: (NSDate*)when