mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
* Headers/Foundation/NSOperation.h
* Source/NSOperation.m: Added initial implementation of NSOperationQueue. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28395 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8ee18b36c7
commit
575500fdf2
3 changed files with 99 additions and 0 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#import <Foundation/NSOperation.h>
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSEnumerator.h>
|
||||
#import <Foundation/NSException.h>
|
||||
|
||||
@implementation NSOperation : NSObject
|
||||
|
@ -145,3 +146,63 @@
|
|||
priority = pri;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSOperationQueue
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if((self = [super init]) != nil)
|
||||
{
|
||||
suspended = NO;
|
||||
count = NSOperationQueueDefaultMaxConcurrentOperationCount;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
// status
|
||||
- (BOOL) isSuspended
|
||||
{
|
||||
return suspended;
|
||||
}
|
||||
|
||||
- (void) setSuspended: (BOOL)flag
|
||||
{
|
||||
suspended = flag;
|
||||
}
|
||||
|
||||
- (NSInteger) maxConcurrentOperationCount
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
- (void) setMaxConcurrentOperationCount: (NSInteger)cnt
|
||||
{
|
||||
count = cnt;
|
||||
}
|
||||
|
||||
// operations
|
||||
- (void) addOperation: (NSOperation *) op
|
||||
{
|
||||
[operations addObject: op];
|
||||
}
|
||||
|
||||
- (NSArray *) operations
|
||||
{
|
||||
return [[NSArray alloc] initWithArray: operations];
|
||||
}
|
||||
|
||||
- (void) cancelAllOperations
|
||||
{
|
||||
NSEnumerator *en = [operations objectEnumerator];
|
||||
id o = nil;
|
||||
while( (o = [en nextObject]) != nil )
|
||||
{
|
||||
[o cancel];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) waitUntilAllOperationsAreFinished
|
||||
{
|
||||
// not yet implemented...
|
||||
}
|
||||
@end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue