mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +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
|
@ -1,3 +1,9 @@
|
||||||
|
2009-07-14 20:02-EDT Gregory John Casamento <greg.casamento@gmail.com>
|
||||||
|
|
||||||
|
* Headers/Foundation/NSOperation.h
|
||||||
|
* Source/NSOperation.m: Added initial implementation of
|
||||||
|
NSOperationQueue.
|
||||||
|
|
||||||
2009-07-13 14:15-EDT Gregory John Casamento <greg.casamento@gmail.com>
|
2009-07-13 14:15-EDT Gregory John Casamento <greg.casamento@gmail.com>
|
||||||
|
|
||||||
* Headers/Foundation/Foundation.h
|
* Headers/Foundation/Foundation.h
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
Boston, MA 02111 USA.
|
Boston, MA 02111 USA.
|
||||||
|
|
||||||
AutogsdocSource: NSOperation.m
|
AutogsdocSource: NSOperation.m
|
||||||
|
AutogsdocSource: NSOperationQueue.m
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <Foundation/NSObject.h>
|
#import <Foundation/NSObject.h>
|
||||||
|
@ -80,3 +81,34 @@ typedef NSInteger NSOperationQueuePriority;
|
||||||
- (NSOperationQueuePriority) queuePriority;
|
- (NSOperationQueuePriority) queuePriority;
|
||||||
- (void) setQueuePriority: (NSOperationQueuePriority)priority;
|
- (void) setQueuePriority: (NSOperationQueuePriority)priority;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NSOperationQueue
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Enumerated type for default operation count.
|
||||||
|
enum {
|
||||||
|
NSOperationQueueDefaultMaxConcurrentOperationCount = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
// NSOperationQueue
|
||||||
|
@interface NSOperationQueue : NSObject
|
||||||
|
{
|
||||||
|
NSMutableArray *operations;
|
||||||
|
BOOL suspended;
|
||||||
|
NSInteger count;
|
||||||
|
}
|
||||||
|
|
||||||
|
// status
|
||||||
|
- (BOOL) isSuspended;
|
||||||
|
- (void) setSuspended: (BOOL)flag;
|
||||||
|
- (NSInteger) maxConcurrentOperationCount;
|
||||||
|
- (void) setMaxConcurrentOperationCount: (NSInteger)cnt;
|
||||||
|
|
||||||
|
// operations
|
||||||
|
- (void) addOperation: (NSOperation *) op;
|
||||||
|
- (NSArray *) operations;
|
||||||
|
- (void) cancelAllOperations;
|
||||||
|
- (void) waitUntilAllOperationsAreFinished;
|
||||||
|
@end
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#import <Foundation/NSOperation.h>
|
#import <Foundation/NSOperation.h>
|
||||||
#import <Foundation/NSArray.h>
|
#import <Foundation/NSArray.h>
|
||||||
|
#import <Foundation/NSEnumerator.h>
|
||||||
#import <Foundation/NSException.h>
|
#import <Foundation/NSException.h>
|
||||||
|
|
||||||
@implementation NSOperation : NSObject
|
@implementation NSOperation : NSObject
|
||||||
|
@ -145,3 +146,63 @@
|
||||||
priority = pri;
|
priority = pri;
|
||||||
}
|
}
|
||||||
@end
|
@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