Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+[BFTask taskFromExecutor:withBlock] to easily create ad-hoc tasks #21

Merged
merged 1 commit into from
May 30, 2014

Conversation

ide
Copy link
Contributor

@ide ide commented Feb 27, 2014

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.

@bklimt
Copy link
Contributor

bklimt commented Mar 7, 2014

Before we review this, would you mind accepting the Facebook contributor license agreement so that we can give you proper attribution if we merge it in? We would really appreciate it. Thanks!

https://developers.facebook.com/opensource/cla

@ide
Copy link
Contributor Author

ide commented Mar 7, 2014

A short while after submitting this diff I filled out the CLA so everything should be set.

@bklimt
Copy link
Contributor

bklimt commented Mar 21, 2014

Our automated systems don't show that you have accepted the CLA. Would you mind double-checking it?

@ide
Copy link
Contributor Author

ide commented Mar 21, 2014

Sure thing - I signed it again.

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.
@bklimt
Copy link
Contributor

bklimt commented May 30, 2014

LGTM. Thanks for the contribution!

bklimt added a commit that referenced this pull request May 30, 2014
+[BFTask taskFromExecutor:withBlock] to easily create ad-hoc tasks
@bklimt bklimt merged commit 3af58ae into BoltsFramework:master May 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants