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

libflux/future: minor interface changes to support composite futures #1188

Merged
merged 7 commits into from
Sep 14, 2017

Conversation

garlick
Copy link
Member

@garlick garlick commented Sep 13, 2017

I noted when implementing some (forthcoming) KVS work that used composite futures (futures within futures, e.g. futures that perform multiple RPCs) that the internal future interfaces were not quite flexible enough to support composite futures, and that we had no tests for composite futures.

This PR makes a minor change to those interfaces, dropping the reactor argument from flux_future_create() and flux_future_init_f, and adding reactor get/set functions.

Tests for several composite future use cases are added and man pages adjusted.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 78.191% when pulling 6b46603 on garlick:compose_future into 8443eff on flux-framework:master.

@codecov-io
Copy link

codecov-io commented Sep 13, 2017

Codecov Report

Merging #1188 into master will decrease coverage by <.01%.
The diff coverage is 89.47%.

@@            Coverage Diff             @@
##           master    #1188      +/-   ##
==========================================
- Coverage   77.78%   77.77%   -0.01%     
==========================================
  Files         158      158              
  Lines       29272    29284      +12     
==========================================
+ Hits        22770    22777       +7     
- Misses       6502     6507       +5
Impacted Files Coverage Δ
src/common/libflux/rpc.c 92.56% <100%> (ø) ⬆️
src/common/libflux/future.c 89.25% <88.23%> (+0.14%) ⬆️
src/common/libflux/request.c 87.17% <0%> (-1.29%) ⬇️
src/common/libkvs/kvs_txn.c 76.47% <0%> (-0.66%) ⬇️
src/modules/kvs/kvs.c 62.89% <0%> (-0.27%) ⬇️
src/common/libkvs/kvs.c 64.83% <0%> (-0.26%) ⬇️
src/common/libflux/message.c 81.17% <0%> (-0.24%) ⬇️
src/broker/overlay.c 72.02% <0%> (ø) ⬆️
src/broker/module.c 83.84% <0%> (+0.27%) ⬆️
... and 3 more

Problem: a composite future's init function needs
to set up continuations for contained futures
using the reactor it is passed, but the reactor
for the contained futures was pre-set when they
were created.

Drop reactor argument from flux_future_create(),
and add flux_future_set_reactor().  Also, if a flux_t
handle is set with flux_future_set_flux(), set the
set the reactor to the one associated with the flux_t
handle as a side-effect.

For symmetry add flux_future_get_reactor() that behaves
like flux_future_get_flux().

A composite future's init function must call
flux_future_get_flux () on the composite future, and
flux_future set_flux() on the contained futures.
Or if there is no flux_t handle involved, call
flux_future_set_reactor() on the contained future with
reactor passed to the init function.  If neither is
called on a future, flux_future_then() fails with EINVAL.

Update rpc.c and future unit test.
Drop the reactor argument from the future's initialization
callback.  It should be accessed in the same manner as
the flux_t handle now that we haver reactor get/set functions.
This makes the API more uniform, and the reactor is often not
used if the future contains message handlers instead of
reactor watchers.

Update rpc implementation and unit test.
Add a test for a future containing a reactor watcher, and
then a future containing two of those futures.
Add a test for a future containing an arbitrary number
of futures that are created on the fly from the contained
futures' continuations until the job is done.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0006%) to 78.137% when pulling 0b3aa3a on garlick:compose_future into 4157888 on flux-framework:master.

@grondo
Copy link
Contributor

grondo commented Sep 14, 2017

Ok, discussed with @garlick offline in a small bit of depth and this is definitely reasonable cleanup at this point. Merging..

@grondo grondo merged commit 06a2ec8 into flux-framework:master Sep 14, 2017
@garlick garlick deleted the compose_future branch September 14, 2017 18:09
@grondo grondo mentioned this pull request May 10, 2018
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.

4 participants