-
Notifications
You must be signed in to change notification settings - Fork 51
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: add flux_future_reset() #1503
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1503 +/- ##
==========================================
- Coverage 78.69% 78.68% -0.01%
==========================================
Files 164 164
Lines 30673 30683 +10
==========================================
+ Hits 24139 24144 +5
- Misses 6534 6539 +5
|
Coverage looks good to me. Only case that doesn't appeared covered is when the timer_watcher needs to be reset instead of created in https://codecov.io/gh/flux-framework/flux-core/pull/1503/diff#D1-194 This actually reminds me of a possible enhancement for Of course this could be done now by keeping a state variable in Perhaps this could be a new function |
Spoke to @garlick and this is already possible, you just have to call One open question was whether |
I'll add a unit test for calling As I think we discussed,
|
Yeah, sorry, I came to the same conclusion in my follow up comment.
Ah good point. I was thinking maybe if the last future result was an error, this code would be triggered if if (f->result_errnum_valid) {
errno = f->result_errnum;
return -1;
} |
Oh indeed you are right about that case of error fulfillment impacting the required order. Thanks! |
5631b59
to
1245390
Compare
Problem: there is no way for a future to be "unfulfilled" in cases where there are multiple events to be handled by the future. Add flux_future_reset(), which sets up the future to be fulfilled again, and invalidates any result currently stored in the future container. Allow flux_future_then() to be optionally called again after flux_future_reset(), to set a timeout or change the continuation callback.
To prepare the way for making flux_future_reset() work on RPC futures to support multiple responses with the same matchtag: 1) drop the rpc->inflight flag and instead call flux_future_wait_for (0) to check if the future is fulfilled before freeing matchtag. 2) Instead of stopping the message handler in the response callback, leave it running.
I fixed a bug, fixed a test bug (that was masking the other bug), and added coverage for calling Then I squashed down the incremental development. |
Great! can this go in? |
Oh, noticed a typo in 1d8f244: |
Sure! |
Er wait, typo! |
Add tests to cover RPCs with multiple responses. An RPC issues a requested number of responses followed by an error response with errnum == ENODATA (like EOF). 1) Call flux_rpc_get() in a loop, with flux_future_reset() after each successful call. Verify that the requetested number of responses was received. 2) Set up a continuation that calls flux_future_reset() after a successful flux_rpc_get(). On failure, verify that the requested number of responses was received. 3) Like #2 except handle the first response in one continuation, and subsequent responses in another. It covers calling flux_future_then() a second time on a future.
Problem: flux_future_wait_for() is shown to return "int bool" in the man page, and flux_future_check() (a removed function) is referenced in RETURN VALUE. Drop the extra "bool". Drop the reference to flux_future_check().
Problem: flux_future_then(3) doesn't get to the point. Make the "base" manual page for _using_ futures flux_future_get(3) instead of flux_future_then(3), which seems a bit more intuitive. Add a prominent reference to flux_future_get(3) at the top of flux_future_create(3), so that one doesn't have to read very far to realize it's man page for class builders not users of such classes.
Since flux_future_get(3) is now the "base" future man page, update references to flux_future_then(3) in the SEE ALSO section of other man pages, where appropriate.
Add a description for flux_future_reset() to the flux_future_get(3) man page.
Problem: flux_future_get(3) includes some details that are not likely to be needed by most users, and this makes it hard to understand. Drop some obscure details that are more or less covered in flux_future_create(3).
This PR adds
flux_future_reset()
, to "unfulfill" a future.The driving use case was RPC with multiple response messages. One can now do this:
or in a continuation, one can conditionally call either
flux_future_reset()
orflux_future_destroy()
before returning. If reset, the continuation will be called on the next fulfillment (RPC response, or whatever).Added unit tests and updated man pages. I reworked the "user" man page a bit for better readability also.
I'd say test coverage might be a little light here, so I'll see how that goes and possibly add more tests.