Skip to main content

with_observer_task

Function with_observer_task 

Source
pub async fn with_observer_task<F, R>(observer: Arc<dyn Observer>, fut: F) -> R
where F: Future<Output = R>,
Expand description

Async sibling of with_test_observer: install the observer in the per-task slot for the duration of fut. This is the version the #[obs::test] async expansion uses so that an emit on a migrated-tokio-worker-thread still resolves to the test observer (the per-thread slot would not be set on the destination worker).

OVERRIDE_COUNT is bumped before entering the scope and decremented after, so the hot-path resolver actually probes the task-local. Spec 11 § 3.1, KD-D3.