Created by: ide
This convenience class method makes it easier to create tasks from blocks
without needing to write the code for a temporary BFTask
or
BFTaskCompletionSource
. Usage:
[[BFTask taskFromExecutor:executor withBlock:id ^{
return work_on_queue();
}] continueWithBlock:...];
As opposed to:
BFTaskCompletionSource *tcs = [BFTaskCompletionSource taskCompletionSource];
dispatch_async(queue, ^{
[tcs setResult:work_on_queue()];
});
[tcs.task continueWithBlock:...];
The convenience method also handles exceptions the same way the rest of BFTasks does so that's another plus.
Test case is included.