[go: up one dir, main page]

Module async_runtime

Module async_runtime 

Source
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§

AsyncRuntime
An Asynchronous Runtime.

Functions§

get_async_runtime
Returns an AsyncRuntime to enable running operations which need to interact with an asynchronous runtime.
set_async_runtime
Sets the current AsyncRuntime to enable running operations which need to interact with an asynchronous runtime.

Type Aliases§

SpawnedTask
A SpawnedTask is a future that represents a running task. It can be awaited to block until the task has completed.
TaskFuture
A TaskFuture is a boxed future that represents a task that can be spawned and executed asynchronously.