Expand description
Communication channels.
Use bounded, unbounded and rendezvous to create channels for use across threads in the same process.
Use ipc_unbounded to create channels that work across processes.
§Examples
use zng_task::{self as task, channel};
let (sender, receiver) = channel::bounded(5);
task::spawn(async move {
task::deadline(5.secs()).await;
if let Err(e) = sender.send("Data!").await {
eprintln!("no receiver connected, did not send message: '{e}'")
}
});
task::spawn(async move {
match receiver.recv().await {
Ok(msg) => println!("{msg}"),
Err(_) => eprintln!("no message in channel and no sender connected"),
}
});Structs§
- IpcBytes
- Immutable bytes vector that can be can be shared fast over IPC.
- IpcBytes
Cast - Safe bytemuck casting wrapper for
IpcBytes. - IpcBytes
Mut - Represents preallocated exclusive mutable memory for a new
IpcBytes. - IpcBytes
MutCast - Safe bytemuck casting wrapper for
IpcBytesMut. - IpcBytes
Writer - Represents an async
IpcByteswriter. - IpcBytes
Writer Blocking - Represents a blocking
IpcByteswriter. - IpcReceiver
- The receiving end of an IPC channel.
- IpcSender
- The transmitting end of an IPC channel.
- Named
IpcReceiver - Init named IPC connection with another process, the receiver end is in the first process.
- Named
IpcSender - Init named IPC connection with another process, the sender end is in the first process.
- Receiver
- The receiving end of a channel.
- Sender
- The transmitting end of a channel.
- Weak
IpcBytes - Weak reference to an in process
IpcBytes.
Enums§
- Channel
Error - Error during channel send or receive.
Traits§
- IpcValue
- Represents a type that can be an input and output of IPC channels.
Functions§
- bounded
- Create a channel with a maximum capacity.
- ipc_
unbounded - Create an unbounded IPC channel.
- is_
ipc_ serialization - Checks if is inside
with_ipc_serialization. - rendezvous
- Create a
boundedchannel with0capacity. - unbounded
- Create a channel with no maximum capacity.
- with_
ipc_ serialization - Enables special serialization of memory mapped files for the
serializecall.