pub struct GracefulIpcChannel<T = Vec<u8>> { /* private fields */ }Expand description
IPC channel with graceful shutdown support
Implementations§
Source§impl<T> GracefulIpcChannel<T>
impl<T> GracefulIpcChannel<T>
Sourcepub fn new(channel: IpcChannel<T>) -> Self
pub fn new(channel: IpcChannel<T>) -> Self
Create a new graceful IPC channel wrapper
Sourcepub fn with_state(channel: IpcChannel<T>, state: Arc<ShutdownState>) -> Self
pub fn with_state(channel: IpcChannel<T>, state: Arc<ShutdownState>) -> Self
Create a new graceful IPC channel with a shared shutdown state
Sourcepub fn create(name: &str) -> Result<Self>
pub fn create(name: &str) -> Result<Self>
Create a new IPC channel server with graceful shutdown
Sourcepub fn connect(name: &str) -> Result<Self>
pub fn connect(name: &str) -> Result<Self>
Connect to an existing IPC channel with graceful shutdown
Sourcepub fn wait_for_client(&mut self) -> Result<()>
pub fn wait_for_client(&mut self) -> Result<()>
Wait for a client to connect (server only)
Sourcepub fn state(&self) -> Arc<ShutdownState>
pub fn state(&self) -> Arc<ShutdownState>
Get the shutdown state for sharing with other channels
Sourcepub fn inner(&self) -> &IpcChannel<T>
pub fn inner(&self) -> &IpcChannel<T>
Get a reference to the inner channel
Sourcepub fn inner_mut(&mut self) -> &mut IpcChannel<T>
pub fn inner_mut(&mut self) -> &mut IpcChannel<T>
Get a mutable reference to the inner channel
Sourcepub fn bind_affinity_thread(&self)
pub fn bind_affinity_thread(&self)
Bind the current thread as the affinity thread for this channel’s reentrancy-safe dispatch queue.
Call this once on the “main” (or named) thread that will drive
pump_pending.
Sourcepub fn submit_reentrant<F, R>(&self, f: F) -> Result<R>
pub fn submit_reentrant<F, R>(&self, f: F) -> Result<R>
Submit f to run on the bound affinity thread in a deadlock-free way.
- Caller is the affinity thread →
fexecutes inline. - Any other thread →
fis queued; the caller blocks untilpump_pendingprocesses it.
Parallel to Swift’s MainActor.assumeIsolated and C#’s
SynchronizationContext.Send.
§Errors
Returns IpcError::Closed if the channel has been shut down or the
affinity thread has been dropped.
Sourcepub fn pump_pending(&self, budget: Duration) -> usize
pub fn pump_pending(&self, budget: Duration) -> usize
Drain at most budget of pending work items on the current thread.
Call this from your host’s idle callback (Maya scriptJob idleEvent,
Unity EditorApplication.update, Unreal FTSTicker, Blender
bpy.app.timers, etc.) to let cross-thread submissions complete.
Returns the number of items processed.
Source§impl GracefulIpcChannel<Vec<u8>>
impl GracefulIpcChannel<Vec<u8>>
Sourcepub fn send_bytes(&mut self, data: &[u8]) -> Result<()>
pub fn send_bytes(&mut self, data: &[u8]) -> Result<()>
Send raw bytes
Sourcepub fn recv_bytes(&mut self) -> Result<Vec<u8>>
pub fn recv_bytes(&mut self) -> Result<Vec<u8>>
Receive raw bytes