Skip to content

Remote completion #1766

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

stbuehler
Copy link
Contributor

Allow polling remote handles (and oneshot channels) for "completion", i.e. when the result is available (poll_ready is used for "ready to send", so I used poll_complete - open to other suggestions), and to extract results without async context.

Add RemoteCompletionHandle<'_> to poll only for completion without extracting the result: can be passed to trait (object) methods as the underlying result type is erased (would be useful in rustasync/runtime#73).

///
/// Panics if underlying future is still running in addition to the
/// ways it would panic when polling `RemoteHandle`.
pub fn recv(mut self) -> T {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some name that might better indicate this panics if still running, unwrap_recv maybe? (I feel like there's a good chance users might assume this does a blocking receive).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Or I could simply remove the method - try_recv should be good enough after all.

Also add recv and try_recv for RemoteHandle.
RemoteCompletionHandle erases the result type of the underlying future
and can be passed to trait object methods to poll only for complection
of the underlying future without retrieving the result.
@taiki-e taiki-e added A-future Area: futures::future and removed futures-util labels Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-future Area: futures::future
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants