Skip to content

Is block_on an executor? #219

@notgull

Description

@notgull

In general, but also in this book, I've heard the word "executor" refer to what I believe are two different concepts:

  • A queue of tasks scheduled to be ran across a set of threads (I would argue this is an executor, and smol::Executor is a good example of this).
  • A system that runs one single task to completion. For example, smol::future::block_on.

I think these are two different concepts, but they're often both referred to as "executors". Executor is not able to poll a future to completion on its own; it requires a top-level block_on for that. On the other hand, block_on on its own can only poll one future to completion.

Internally I've referred to the latter case (block_on) as a "reactor"; however it seems this is incorrect. async_io::block_on is fairly certainly a reactor, since it handles I/O events and timers.

However, futures_lite::block_on is in a gray area here. It handles no I/O events, it just polls the future to completion. I would argue that this is a reactor in the same way that () is a type.

I'm wondering if the book can be updated to clarify the differences here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions