Skip to main content

Module async_api

Module async_api 

Source
Available on crate feature async only.
Expand description

Executor-agnostic async instrumentation helpers for OSActivity.

Enable this module with the async Cargo feature:

[dependencies]
apple-log = { version = "0.6", features = ["async"] }

ActivityFuture wraps any Future and enters an OSActivity around each poll. This keeps activity scoping aligned with executor wakeups without holding a scope guard across suspension points.

§Example

use apple_log::{OSActivity, OSActivityFlags};

let bytes = OSActivity::new(
    "download asset",
    Some(&OSActivity::current()),
    OSActivityFlags::DEFAULT,
)?
.instrument_future(async { 42_usize })
.await?;

assert_eq!(bytes, 42);

Structs§

ActivityFuture
Future wrapper that re-enters an OSActivity every time the executor polls it.

Functions§

instrument_future
Wrap future so each poll executes inside activity.