Latest2.0
Homepagehttps://github.com/nobre84/RNConcurrentBlockOperation
LicenseMIT
Authors

RNConcurrentBlockOperation is a simple NSOperation subclass, similar to NSBlockOperation. It allows a block of work that is potentially asynchrounous to be submited into a NSOperationQueue for parallel execution.

Sample usage:


    NSOperationQueue *queue = [NSOperationQueue new];
    queue.maxConcurrentOperationCount = 5;
    // Regular usage, only finishes the operation
    [queue addOperation:[RNConcurrentBlockOperation operationWithBlock:^(RNCompletionBlock completion) {
        NSLog(@"Concurrent op started");
        //Some async operation
        //... ... ...
        //Async operation completed
        completion(nil);
    }]];
    // Cancelled operation, cancels then finish the operation
    [queue addOperation:[RNConcurrentBlockOperation operationWithBlock:^(RNCompletionBlock completion) {
        NSLog(@"Cancellable op started");
        //Some async operation
        //... ... ...
        //Something happened (i.e user cancelled, network outage), and we want to bail
        //Async operation cancelled
        NSError *error = [NSError new]; //Some possible error
        completion(@{RNOperationStatusKey: RNOperationStatusCanceled, RNOperationErrorKey: error});
    }]];
    // Store the operation value in the userInfo dictionary and finishes it.
    [queue addOperation:[RNConcurrentBlockOperation operationWithBlock:^(RNCompletionBlock completion) {
        NSLog(@"Concurrent op started with result");
        NSString *result = @"A string generated by the async operation";
        completion(@{RNOperationResultKey: result});
    }]];  

Latest podspec

{
    "name": "RNConcurrentBlockOperation",
    "version": "2.0",
    "summary": "Simple NSOperation subclass that allows a block of asynchronous work to be executed in parallel in a NSOperationQueue",
    "description": "RNConcurrentBlockOperation is a simple NSOperation subclass, similar to NSBlockOperation. It allows a block of work that is potentially asynchrounous to be submited into a NSOperationQueue for parallel execution. It allows for cancellation of submitted blocks and returning arbitrary results from your operation.",
    "homepage": "https://github.com/nobre84/RNConcurrentBlockOperation",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Rafael Nobre": "[email protected]"
    },
    "source": {
        "git": "https://github.com/nobre84/RNConcurrentBlockOperation.git",
        "tag": "2.0"
    },
    "source_files": "RNConcurrentBlockOperation.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This