Skip to content

thread_pool: missing launch function and no stop_token injection #163

@vinniefalco

Description

@vinniefalco

There's no way to inject a stop_token into the task posted to the thread pool. In fact there's no real IoAwaitable interface at all. The only options are:

thread_pool tp;

run_async( ex.get_executor() )( my_task() );

co_await run( ex.get_executor() )( my_task() );

But what does this even mean? where is the suspension mechanism for run? it blocks on a task submitted to a foreign executor? The injected stop token is.. nothing? should run with no stop token acquire the stop token from the environment in order to connect it to the caller's stop token?

What if someone wants to stop all tasks in the thread pool, there would need to be one stop source and its stop tokens are distributed to every submitted awaitable but there's no way to do that with the current API.

run_async cannot propagate a stop token since its not a coroutine. But run can, and probably should.

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