doc-push icon indicating copy to clipboard operation
doc-push copied to clipboard

doc: TaskExecutor

Open bbigras opened this issue 7 years ago • 4 comments

The user of TaskExecutor must ensure that when a future is submitted, that it is done within the context of a call to run.

For more details, see the module level documentation.

https://docs.rs/tokio/0.1.11/tokio/runtime/current_thread/struct.TaskExecutor.html#method.current

I'm confused by the "within the context of a call to run" part. Does it just mean that I must only call current() from code being executed by tokio?

bbigras avatar Oct 09 '18 18:10 bbigras

You are correct, that is very poorly worded.

Basically, you need to use TaskExecutor from a future spawned on tokio::run. TaskExecutor uses a thread-local variable referencing the "current executor". Until you are running on the tokio runtime (with tokio::run) that thread-local is not set.

Does that make sense?

carllerche avatar Oct 09 '18 20:10 carllerche

Yes it does, thanks!

bbigras avatar Oct 10 '18 05:10 bbigras

Great. This issue can be closed once the API docs have been updated.

carllerche avatar Oct 10 '18 15:10 carllerche

Great. This issue can be closed once the API docs have been updated.

It would be good to have some theroy guide or reference regardless of code and language.

shaitao avatar Dec 04 '18 11:12 shaitao