Skip to content

Consider an opt-in asyncband::block_on module #147

Description

@tisonkun

Motivation

asyncband deliberately exposes runtime-agnostic async primitives and avoids adding a blocking variant for every primitive. Users who need a small synchronous facade currently have to choose and depend on a separate executor just to block on an operation such as Mutex::lock.

For a future release, consider providing a lightweight, opt-in bridge based on pollster:

  • A free block_on function that runs an IntoFuture to completion while parking the current thread.
  • A FutureExt extension trait that supports the suffix-style .block_on() call.

The API could tentatively live under asyncband::block_on:

use asyncband::block_on::{block_on, FutureExt as _};

let guard = block_on(mutex.lock());
let guard = mutex.lock().block_on();

This would let users build convenient synchronous wrappers around async primitives without adding blocking methods to every primitive.

Constraints and open questions

  • The API must be disabled by default and enabled through an opt-in Cargo feature.
  • The default asyncband API and build dependency tree should remain unchanged.
  • This should remain a lightweight single-future executor, not a general-purpose async runtime.
  • Documentation should clarify that futures depending on runtime-specific drivers may not make progress, and that blocking from an async executor thread can cause starvation or deadlocks.
  • asyncband::block_on, the Cargo feature name, and whether to adapt the implementation or use an optional dependency are tentative design choices.

This issue records a direction to consider for a later release, rather than a commitment to a specific API or release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions