Struct RuntimeSender

Source
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>.

Source

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));
Source

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));
Source

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);
Source

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>.

Source§

fn clone(&self) -> Self

Produces the clone required by the standard cloning contract.

1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<A> Debug for RuntimeSender<A>

Implements the fmt::Debug contract for RuntimeSender<A>.

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value for human-readable diagnostics.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<A> IntoClickAction<A> for A
where A: Clone + 'static,

Source§

fn into_click_action(self) -> ClickAction<A>

Implements the into_click_action helper used by this module.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Props for T
where T: Clone + 'static,