From e2d66ee254ce7e5915f09a13864139ba335d99d5 Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Tue, 28 Jul 2015 20:08:10 +0000 Subject: [PATCH] add startup and shutdown methods git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/performance/trunk@38844 72102866-910b-0410-8b05-ffd578937521 --- GSIOThreadPool.h | 10 ++++++++++ GSIOThreadPool.m | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/GSIOThreadPool.h b/GSIOThreadPool.h index c5f6223..258744b 100644 --- a/GSIOThreadPool.h +++ b/GSIOThreadPool.h @@ -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).
+ * Does nothing, provided for subclasses to override. + */ +- (void) shutdown; + +/** Called when the thread is started up (before the run loop starts).
+ * Does nothing, provided for subclasses to override. + */ +- (void) startup; @end /** This class provides a thread pool for performing methods which need to diff --git a/GSIOThreadPool.m b/GSIOThreadPool.m index a259352..6ef9993 100644 --- a/GSIOThreadPool.m +++ b/GSIOThreadPool.m @@ -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