Skip to main content

cubecl_environment/future/
channel.rs

1//! Channel types shared across environments.
2//!
3//! Re-exports the channels used throughout `CubeCL` so consumers don't depend on
4//! the underlying crates directly.
5
6pub use async_channel::{
7    Receiver, RecvError, SendError, Sender, TryRecvError, TrySendError, bounded, unbounded,
8};
9
10/// One-shot channels: a single value handed from one task to another.
11///
12/// # Blocking
13///
14/// [`Receiver::recv`] parks the calling thread, which on wasm is the browser's
15/// only thread: it hangs the event loop with no diagnostic, unlike
16/// [`block_on`](super::block_on) and [`read_sync`](super::read_sync), which
17/// handle that target explicitly. Await the receiver instead — that works
18/// everywhere. The blocking receive is only used from `multi_threading` code
19/// paths.
20///
21/// Absent on a target whose atomics carry no compare-and-swap (thumbv6m):
22/// `oneshot` needs it and has no fallback. Every consumer needs `std` or the
23/// browser, so nothing that could run there loses anything.
24#[cfg(target_has_atomic = "ptr")]
25pub mod oneshot {
26    // A glob because the error types are conditionally compiled on the
27    // underlying crate's features; naming them would break feature combinations
28    // rather than document them.
29    pub use ::oneshot::*;
30}