global_cell 0.2.0

A thread-safe, async-friendly, performant global cell alternative built on Rust and Tokio primitives
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
// Miscellaneous utility functions for Cells.
use futures_util::future::poll_fn;
use std::task::Poll;

/// Offers the current thread's remaining time slice to other threads.
/// Generalized to any async runtime.
pub(crate) async fn yield_now() {
    poll_fn(|cx| {
        cx.waker().wake_by_ref();
        Poll::<()>::Pending
    }).await;
}