//
//  NSThreadWaiter.h
//  NSThreadExtension
//
//  Created by Jonathan Lung on 10/03/07.
//  Copyright 2007 Jonathan Lung. All rights reserved.
//  http://www.cs.toronto.edu/~lungj

#import <Cocoa/Cocoa.h>

/*!
    @class
    @abstract    Adds the ability to wait for a thread to wait until
					a certain number of threads exist.
    @discussion  When waiting for the number of running threads to drop
					to a certain value, this is like joining threads
					without specifying which threads are joined.
*/

@interface NSThread (Waiting)
+ (void)detachNewCountedThreadSelector:(SEL)aSelector toTarget:(id)aTarget withObject:(id)anArgument;
/*!
    @method     
    @abstract   Causes the calling thread to block until numberOfThreads remain.
    @discussion Block until the number of threads detached by
				detachNewCountedThreadSelector:toTarget:withObject: reaches numberOfThreads.
				If multiple threads finish or start before the thread calling
				this method is signalled such that the number of
				counted threads is not equal to numberOfThreads, this thread
				may continue to block.
				
				N.B.: threads not detached explicitly using
				detachNewCountedThreadSelector:toTarget:withObject:
				will not be counted as running.
				
*/
+ (void)sleepUntilThreadsNumber:(int) numberOfThreads;
/*!
    @method     
    @abstract   Returns the number of running threads.
    @discussion Returns the number of threads detached by
				detachNewCountedThreadSelector:toTarget:withObject:.
				
				N.B.: threads not detached explicitly using
				detachNewCountedThreadSelector:toTarget:withObject:
				will not be counted as running.
				
*/
+ (int)detachedThreads;
@end

