Grand Object Dispatch
Objective-C wrapper for Grand Central Dispatch with method for every single dispatch call and with some useful additions.
Contribution in form of Pull Requests, Feature Requests or Issues is welcome! Especially suggesing improved API for Dispatch Sources, Dispatch IO and Dispatch Data would be really appreciated.
Additions
- Detection of Current Queue using
dispatch_get_specific
. - Deadlock-safe
-sync:
method. - Convenience initializer for reverse-DNS label.
- Accessors for Main Queue and Global Concurrent Queues.
- Method
-log:
which is replacement for deprecateddispatch_debug
. - Better macro for
dispatch_once
. - Waiting methods for Semaphores and Groups taking time interval or date or waiting forever.
- Specific class for Dispatch Timer (Dispatch Source of type Timer).
Example Code
Grand Object Dispatch
GODQueue *clusterQueue = [[GODQueue alloc] initWithName:@"cluster" concurrent:YES];
GODQueue *isolationQueue = [[GODQueue alloc] initWithName:@"isolation" concurrent:YES];
[clusterQueue apply:100 block:^(NSUInteger index) {
[isolationQueue sync:^{
// access shared resource
}];
// iterative calculation
[isolationQueue barrierAsync:^{
// modify shared resource
}];
}];
[clusterQueue barrierAsync:^{
// finalize data
[[GODQueue mainQueue] async:^{
// update UI
}];
}];
Grand Central Dispatch
dispatch_queue_t clusterQueue = dispatch_queue_create("cluster", DISPATCH_QUEUE_CONCURRENT);
dispatch_queue_t isolationQueue = dispatch_queue_create("isolation", DISPATCH_QUEUE_CONCURRENT);
dispatch_apply(100, clusterQueue, ^(size_t index) {
dispatch_sync(isolationQueue, ^{
// access shared resource
});
// iterative calculation
dispatch_barrier_async(isolationQueue, ^{
// modify shared resource
});
});
dispatch_barrier_async(clusterQueue, ^{
// finalize data
dispatch_async(dispatch_get_main_queue(), ^{
// update UI
});
});
Implemented (or not yet)
- Dispatch Objects
- Dispatch Queues
- Dispatch Groups
- Dispatch Semaphores
- Dispatch Sources
- Dispatch IO
- Dispatch Data
Version 0.5.0
MIT License, Copyright Β© 2013 Martin Kiss
THE SOFTWARE IS PROVIDED "AS IS", and so on...
see LICENSE.md
for more.