smol-rs / async-task

Task abstraction for building executors
Apache License 2.0
398 stars 39 forks source link

overgeneral documentation #77

Open lolbinarycat opened 4 months ago

lolbinarycat commented 4 months ago

All executors have a queue that holds scheduled tasks:

this is not always true. a simple implications of block_on that loops until it receives Ready does not fulfill this. perhaps you meant to refer to a task named Exexutor?

notgull commented 4 months ago

There's some confusion in the async ecosystem over what an executor is.

For some reason reactors are sometimes called executors. Maybe because in tokio their executor is also their reactor.

lolbinarycat commented 4 months ago

hmm, the async book isn't super clear about this. it says that executors are responsible for polling futures (which lines up with the std::task documentation, which seems to consider anything that calls Future::poll an executor), while reactors are responsible for async io and the like.

so i think that both would be considered an executor, while a reactor would be something like the blocking crate or tokio_uring.

nonetheless, the statement is still incorrect, as executors like futures::block_on don't have any internal queues, as they only support a single task. and i don't buy the idea that this is somehow a reactor, as it is specifically given as an example of an executor by the async book, and it does not implement any sort of async io.

notgull commented 4 months ago

while reactors are responsible for async io and the like.

Eh, I'd argue otherwise. futures_lite::block_on is a reactor in the same way () is a type. It runs a future and delivers events, it's just that the only event it delivers is waking up the future.

it is specifically given as an example of an executor by the async book, and it does not implement any sort of async io.

I think I'll raise an issue on the async book.

lolbinarycat commented 4 months ago

even if "all executors can handle multiple tasks" is true, this is still overgeneral, since the executor could use some other non-queue datastructure like a red-black tree (such as the old linux CFS does)