tokio icon indicating copy to clipboard operation
tokio copied to clipboard

task: stabilize `Builder`

Open ipetkov opened this issue 2 years ago • 7 comments

This is a meta issue tracking the stabilization of task::Builder. Outstanding issues to consider:

  • [x] make spawn* methods fallible. Much like std::thread::Builder::spawn is a non-panicking alternative to std::thread::spawn, applications should be able to use task::Builder::spawn* as a non-panicking alternative to tokio::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 selfparameter on spawn methods: most take self, but spawn_ontakes &mut self #4953

ipetkov avatar Jul 20 '22 23:07 ipetkov

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.

carllerche avatar Aug 01 '22 18:08 carllerche

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...

hawkw avatar Aug 01 '22 19:08 hawkw

#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 avatar Aug 29 '22 20:08 hawkw

@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 avatar Aug 29 '22 23:08 ipetkov

@ipetkov so we were gonna stabilize JoinSet in the next release...

Noah-Kennedy avatar Aug 30 '22 00:08 Noah-Kennedy