Author: rfm
Date: Tue Jul 28 21:16:21 2015
New Revision: 38842
URL: http://svn.gna.org/viewcvs/gnustep?rev=38842&view=rev
Log:
Add support for setting the thread class
Modified:
libs/performance/trunk/GSIOThreadPool.h
libs/performance/trunk/GSIOThreadPool.m
Modified: libs/performance/trunk/GSIOThreadPool.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/performance/trunk/GSIOThreadPool.h?rev=38842&r1=38841&r2=38842&view=diff
==============================================================================
--- libs/performance/trunk/GSIOThreadPool.h (original)
+++ libs/performance/trunk/GSIOThreadPool.h Tue Jul 28 21:16:21 2015
@@ -64,6 +64,7 @@
NSMutableArray *threads;
NSTimeInterval timeout;
NSUInteger maxThreads;
+ Class threadClass;
}
/** Returns an instance intended for sharing between sections of code which
@@ -80,7 +81,9 @@
/** Selects a thread from the pool to be used for some job.<br />
* This method selectes the least used thread in the pool (ie the
- * one with the lowest acquire count).
+ * one with the lowest acquire count).<br />
+ * If the receiver is configured with a size of zero, the main thread
+ * is returned.
*/
- (NSThread*) acquireThread;
@@ -91,6 +94,11 @@
/** Returns the currently configured maximum number of threads in the pool.
*/
- (NSUInteger) maxThreads;
+
+/* Sets the class to be used to create any new threads in this pool.<br />
+ * Must be a subclass of the GSIOThread class.
+ */
+- (void) setThreadClass: (Class)aClass;
/** Specify the maximum number of threads in the pool (the actual number
* used may be lower than this value).<br />
Modified: libs/performance/trunk/GSIOThreadPool.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/performance/trunk/GSIOThreadPool.m?rev=38842&r1=38841&r2=38842&view=diff
==============================================================================
--- libs/performance/trunk/GSIOThreadPool.m (original)
+++ libs/performance/trunk/GSIOThreadPool.m Tue Jul 28 21:16:21 2015
@@ -213,7 +213,7 @@
t = best(threads);
if (nil == t || ((c = [t _count]) > 0 && [threads count] < maxThreads))
{
- t = [GSIOThread new];
+ t = [threadClass new];
[threads addObject: t];
[t release];
c = 0;
@@ -263,6 +263,7 @@
if ((self = [super init]) != nil)
{
threads = [NSMutableArray new];
+ threadClass = [GSIOThread class];
}
#else
[self release];
@@ -280,6 +281,16 @@
- (void) setThreads: (NSUInteger)max
{
maxThreads = max;
+}
+
+- (void) setThreadClass: (Class)aClass
+{
+ if (NO == [aClass isSubclassOfClass: [GSIOThread class]])
+ {
+ [NSException raise: NSInvalidArgumentException
+ format: @"Thread class must be a subclass of GSIOThread"];
+ }
+ threadClass = aClass;
}
- (void) setTimeout: (NSTimeInterval)t
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs