Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Make
futures::future::Pending<T>
implementClone
.Motivation
I am writing a program that uses tokio-timer's
Delay
in a loop to asynchronously sleep for a long time, e.g. 5 minutes. If my program receives a shutdown signal I want to interrupt the sleep early and exit the loop. My plan for doing so was to use theAbortable
future support from this crate to propagate the shutdown signal.My loop would basically look like this:
The only problem is that I am running this loop on multiple threads, so
Abortable<Pending<()>>
needs to be Send, Sync, and Clone.Abortable
is all three already andPending
is Send + Sync, but not Clone. I worked around this by writing my ownPending
struct that is Clone, but I'd prefer to use the one from futures-util.Alternatives
An alternative to this PR would be if there is a simpler preexisting way of accomplishing my goal above that I don't know about. I tried to use the
oneshot
channel, but theReceiver
is not Clone, which I think makes sense given that its a single-consumer channel.