mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Add addOperationWithBlock: to NSOperationQueue
This commit is contained in:
parent
88dd60a8fc
commit
2553b6d56d
2 changed files with 13 additions and 2 deletions
|
@ -37,7 +37,8 @@ extern "C" {
|
|||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
|
||||
#import <GNUstepBase/GSBlocks.h>
|
||||
DEFINE_BLOCK_TYPE_NO_ARGS(GSOperationCompletionBlock, void);
|
||||
#endif
|
||||
DEFINE_BLOCK_TYPE(GSBlockOperationBlock, void, void);
|
||||
#endif
|
||||
|
||||
@class NSMutableArray;
|
||||
|
||||
|
@ -211,7 +212,6 @@ typedef NSInteger NSOperationQueuePriority;
|
|||
}
|
||||
|
||||
// Managing the blocks in the Operation
|
||||
DEFINE_BLOCK_TYPE(GSBlockOperationBlock, void, void);
|
||||
+ (instancetype)blockOperationWithBlock: (GSBlockOperationBlock)block;
|
||||
- (void)addExecutionBlock: (GSBlockOperationBlock)block;
|
||||
- (NSArray *) executionBlocks;
|
||||
|
@ -259,6 +259,10 @@ enum {
|
|||
*/
|
||||
- (void) addOperations: (NSArray *)ops
|
||||
waitUntilFinished: (BOOL)shouldWait;
|
||||
|
||||
/** This method wraps a block in an operation and adds it to the queue.
|
||||
*/
|
||||
- (void) addOperationWithBlock: (GSBlockOperationBlock)block;
|
||||
#endif
|
||||
|
||||
/** Cancels all outstanding operations in the queue.
|
||||
|
|
|
@ -674,6 +674,13 @@ static NSOperationQueue *mainQueue = nil;
|
|||
[internal->lock unlock];
|
||||
}
|
||||
|
||||
- (void) addOperationWithBlock: (GSBlockOperationBlock)block
|
||||
{
|
||||
NSBlockOperation *bop = [NSBlockOperation blockOperationWithBlock: block];
|
||||
[self addOperation: bop];
|
||||
}
|
||||
|
||||
|
||||
- (void) addOperations: (NSArray *)ops
|
||||
waitUntilFinished: (BOOL)shouldWait
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue