tokio
tokio copied to clipboard
task: stabilize `Builder`
This is a meta issue tracking the stabilization of task::Builder
. Outstanding issues to consider:
- [x] make
spawn*
methods fallible. Much likestd::thread::Builder::spawn
is a non-panicking alternative tostd::thread::spawn
, applications should be able to usetask::Builder::spawn*
as a non-panicking alternative totokio::spawn
#4823 - [ ] is
io::Error
the correct type to use/stabilize for spawn errors? - [ ] Fallible spawn methods have not yet landed on a tokio release (1.21 will include them), should we wait for feedback after the breakage before stabilizing?
- [x] revisit consistency of
self
parameter on spawn methods: most takeself
, butspawn_on
takes&mut self
#4953
For the spawn error, we do have additional cases than thread spawning, e.g. "the runtime is shutdown". This makes me think we should introduce a new error type.
We should include 1 or 2 cycles for getting feedback and should put out a call for comments so people know this is coming.
For the spawn error, we do have additional cases than thread spawning, e.g. "the runtime is shutdown". This makes me think we should introduce a new error type.
A SpawnError
type can also wrap an io::Error
and have it as a source
, in the case that the error is not that the runtime is shutdown...
#4955 is another case where, if we added that kind of API, we would be introducing another error variant that doesn't really map directly to an io::Error
variant.
I think we may want to have a tokio::task::SpawnError
whose source
might be an io::Error
, rather than returning an io::Error
that's internally a SpawnError
...
@hawkw we should probably extend this model to JoinSet
as well (return custom errors instead of io::Error
)
EDIT: we should apply this to the JoinSet
builder which is still unstable
@ipetkov so we were gonna stabilize JoinSet
in the next release...