Expand description
§executor-core
A flexible task executor abstraction layer for Rust async runtimes.
This crate provides unified traits and type-erased wrappers for different async executors, allowing you to write code that’s agnostic to the underlying executor implementation.
§Overview
The crate is built around two main traits:
Executor: For spawningSend + 'staticfuturesLocalExecutor: For spawning'staticfutures (not necessarilySend)
Both traits produce tasks that implement the Task trait, providing:
Futureimplementation for awaiting resultsTask::poll_resultfor explicit error handlingTask::detachfor fire-and-forget tasks
§Features
- Zero-cost Executor Abstraction: Unified
ExecutorandLocalExecutortraits using Generic Associated Types (GAT) to prevent unnecessary heap allocation and dynamic dispatch - Type Erasure:
AnyExecutorandAnyLocalExecutorfor runtime flexibility - Task Management: Panic-aware
Task::resultand background execution withTask::detach - No-std Compatible: Core functionality works in no-std environments
- Panic Safety: Proper panic handling and propagation
§Lifetime Constraints
The current API requires 'static lifetimes for both futures and their outputs.
This constraint comes from the underlying async runtimes and ensures memory safety
when tasks may outlive their spawning scope. While this limits flexibility, it
matches the constraints of most async runtime implementations in Rust.
Modules§
- async_
executor async-executor - Integration with the
async-executorcrate. - async_
task async-task - Integration with the
async-taskcrate. - mailbox
- Mailbox-based message passing for safe cross-thread communication.
- tokio
tokio - Integration with the Tokio async runtime.
Structs§
- AnyExecutor
- A type-erased
Executorthat can hold any executor implementation. - AnyExecutor
Task - Task type returned by
AnyExecutor. - AnyLocal
Executor - A type-erased
LocalExecutorthat can hold any local executor implementation. - AnyLocal
Executor Task - Task type returned by
AnyLocalExecutor. - Default
Executor std - A default executor that uses the global and local executors.
- Result
Future - Future returned by
Task::result().
Traits§
- Executor
- A trait for spawning
Send + 'staticfutures. - Local
Executor - A trait for spawning
'staticfutures that may not beSend. - Task
- A trait representing a spawned task that can be awaited or queried for results.
Functions§
- init_
global_ executor std - Initialize the global executor for spawning Send futures.
- init_
local_ executor std - Initialize the thread-local executor for spawning non-Send futures.
- spawn
std - Spawn a
Sendfuture on the global executor. - spawn_
local std - Spawn a future on the thread-local executor.
- try_
init_ global_ executor std - Try to initialize the global executor for spawning Send futures.
- try_
init_ local_ executor std - Try to initialize the thread-local executor for spawning non-Send futures.