-
Notifications
You must be signed in to change notification settings - Fork 40
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
Added a way to obtain an indication of the current task state #19
Conversation
Some options to remove the
|
I'm fine with bumping MSRV to 1.40. |
Rebased onto master |
src/task.rs
Outdated
if state & (CLOSED | COMPLETED) != 0 { | ||
TaskState::Completed | ||
} else { | ||
TaskState::Running | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering that TaskState
is non_exhaustive
, the user can really only rely on state==Completed
(since state==Running
may change its meaning in the future).
So I am starting to think that it might actually be preferable to have a method that returns a bool like is_completed
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std JoinHandle has a similar unstable feature, which appears to be planned to be renamed is_finished.
rust-lang/rust#94549
Switched to |
LGTM. Could you revert MSRV bump? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Published in 4.2.0. |
I ran into the issue a couple of times where I spawned a task with async_std::task::spawn, and I was interested in getting an indication of the state of this task.
In my specific case I'm spawning up a task that takes data from a
TcpStream
and sends it to aSender
. This task does not have a noticeable output, however I would like to periodically check if this task is still running and didn't panic or something.