pub struct RuntimeSender<A> { /* private fields */ }Expand description
Cloneable producer for a bounded runtime mailbox.
Clones share queue, redraw-coalescing state, wake state, and counters.
RuntimeSender<A> is suitable across threads when A: Send; it never
accesses the UI-local RuntimeHandle from producers.
§Examples
use std::num::NonZeroUsize;
use ailloli_ui_runtime::app::RuntimeInbox;
let (sender, _inbox) = RuntimeInbox::<String>::channel(NonZeroUsize::new(4).unwrap());
assert_eq!(sender.stats().enqueued, 0);Implementations§
Source§impl<A> RuntimeSender<A>
Provides the operations defined for RuntimeSender<A>.
impl<A> RuntimeSender<A>
Provides the operations defined for RuntimeSender<A>.
Sourcepub fn dispatch(&self, action: A) -> Result<(), RuntimeSendError>
pub fn dispatch(&self, action: A) -> Result<(), RuntimeSendError>
Enqueues one application action without accessing RuntimeHandle
across threads.
The operation is nonblocking. EnqueuedButWakeFailed leaves the action
queued; Full and Closed do not. Actions are not coalesced.
§Errors
Returns RuntimeSendError::Full or RuntimeSendError::Closed when
the action is not enqueued. RuntimeSendError::EnqueuedButWakeFailed
means the action remains queued but the host wake failed.
§Examples
use std::num::NonZeroUsize;
use ailloli_ui_runtime::app::{RuntimeInbox, RuntimeSendError};
let (sender, _inbox) = RuntimeInbox::channel(NonZeroUsize::new(1).unwrap());
sender.dispatch(1).unwrap();
assert_eq!(sender.dispatch(2), Err(RuntimeSendError::Full));Sourcepub fn request_redraw(&self) -> Result<(), RuntimeSendError>
pub fn request_redraw(&self) -> Result<(), RuntimeSendError>
Requests a redraw of every logical window.
At most one outstanding RedrawAll message is queued. Repeated calls
increment coalesced and retry host wake without consuming capacity.
Per-window redraw messages remain independent.
§Errors
Returns RuntimeSendError::Full or RuntimeSendError::Closed when a
new redraw message cannot be enqueued. A coalesced or newly enqueued
request returns RuntimeSendError::EnqueuedButWakeFailed if waking the
host fails; the pending redraw marker remains set in that case.
§Examples
use std::num::NonZeroUsize;
use ailloli_ui_runtime::app::RuntimeInbox;
let (sender, _inbox) = RuntimeInbox::<()>::channel(NonZeroUsize::new(2).unwrap());
sender.request_redraw().unwrap();
sender.request_redraw().unwrap();
assert_eq!((sender.stats().enqueued, sender.stats().coalesced), (1, 1));Sourcepub fn request_window_redraw(
&self,
logical_window_id: impl Into<LogicalWindowId>,
) -> Result<(), RuntimeSendError>
pub fn request_window_redraw( &self, logical_window_id: impl Into<LogicalWindowId>, ) -> Result<(), RuntimeSendError>
Requests a redraw of one stable logical window.
At most one outstanding message per exact logical ID is queued. Duplicate
requests increment coalesced; different windows consume separate
capacity. Failed enqueue removes the pending marker so retry can enqueue.
§Errors
Returns RuntimeSendError::Full or RuntimeSendError::Closed when a
new window redraw cannot be enqueued. A coalesced or newly enqueued
request returns RuntimeSendError::EnqueuedButWakeFailed if the host
wake fails; the pending marker remains set after that wake-only failure.
§Examples
use std::num::NonZeroUsize;
use ailloli_ui_runtime::app::RuntimeInbox;
let (sender, _inbox) = RuntimeInbox::<()>::channel(NonZeroUsize::new(2).unwrap());
sender.request_window_redraw("main").unwrap();
sender.request_window_redraw("main").unwrap();
assert_eq!(sender.stats().coalesced, 1);Sourcepub fn stats(&self) -> RuntimeInboxStats
pub fn stats(&self) -> RuntimeInboxStats
Returns a non-resetting shared instrumentation snapshot.
§Examples
use std::num::NonZeroUsize;
use ailloli_ui_runtime::app::RuntimeInbox;
let (sender, _inbox) = RuntimeInbox::channel(NonZeroUsize::new(1).unwrap());
sender.dispatch(3).unwrap();
assert_eq!(sender.stats().enqueued, 1);Trait Implementations§
Source§impl<A> Clone for RuntimeSender<A>
Implements the Clone contract for RuntimeSender<A>.
impl<A> Clone for RuntimeSender<A>
Implements the Clone contract for RuntimeSender<A>.
Auto Trait Implementations§
impl<A> Freeze for RuntimeSender<A>
impl<A> RefUnwindSafe for RuntimeSender<A>
impl<A> Send for RuntimeSender<A>where
A: Send,
impl<A> Sync for RuntimeSender<A>where
A: Send,
impl<A> Unpin for RuntimeSender<A>
impl<A> UnwindSafe for RuntimeSender<A>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
Source§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.