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

Blocking futures support #1

Closed
wants to merge 6 commits into from
Closed

Blocking futures support #1

wants to merge 6 commits into from

Conversation

agrippa
Copy link
Contributor

@agrippa agrippa commented Dec 17, 2015

This diff adds support for future-esque asyncs and blocking on DDFs, in both the C and C++ APIs. In particular, it adds the following functions to the C API:

/*
 * Block the currently executing task on the provided DDF. Returns the datum
 * that was put on ddf.
 */
void *hclib_ddf_wait(hclib_ddf_t *ddf);
/*
 * Spawn an async that automatically puts a DDF on termination.
 */
hclib_ddf_t *hclib_async_future(generic_framePtr fp, void *arg,
        hclib_ddf_t **ddf_list, struct _phased_t *phased_clause,
        int property);

hclib_async_future is the simpler to implement, we just allocate a DDF and wrap the user function so that we can do a ddf_put on completion.

hclib_ddf_wait uses the lightweight context work to swap off the current context on a wait, entering the main work-stealing loop instead. This implementation is based on the support needed to block on end-finishes.

I've also added equivalent C++ APIs, and added a couple of tests for both APIs (future0 and future1).

This diff is based off of merge, so I'll merge this stuff into merge before merging merge into master (now that sentence wasn't hard to follow was it?).

@agrippa
Copy link
Contributor Author

agrippa commented Dec 18, 2015

Merged into master locally.

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.

3 participants