Expand description
Asynchronous task execution utilities.
This module provides a mechanism to spawn tasks asynchronously and wait for their completion.
It abstracts away the underlying implementation details, allowing for different task execution strategies based on the target architecture and features enabled.
§Examples
use typespec_client_core::async_runtime::get_async_runtime;
let async_runtime = get_async_runtime();
let handle = async_runtime.spawn(Box::pin(async {
// Simulate some work
std::thread::sleep(std::time::Duration::from_secs(1));
}));
handle.await.expect("Task should complete successfully");
println!("Task completed");Traits§
- Async
Runtime - An Asynchronous Runtime.
Functions§
- get_
async_ runtime - Returns an
AsyncRuntimeto enable running operations which need to interact with an asynchronous runtime. - set_
async_ runtime - Sets the current
AsyncRuntimeto enable running operations which need to interact with an asynchronous runtime.
Type Aliases§
- Spawned
Task - A
SpawnedTaskis a future that represents a running task. It can be awaited to block until the task has completed. - Task
Future - A
TaskFutureis a boxed future that represents a task that can be spawned and executed asynchronously.