Skip to main content

Posts

Struct Posts 

Source
pub struct Posts(/* private fields */);
Expand description

The calls of JS functions Rust posts (super::Callback::post, call_async) for the next JS turn, in one ordered queue. One per engine, made by it and handed to nsh-js and the core. Cheap to clone.

The calls run in the order they were posted, with one exception that keeps JS’s program order: a call posted during a synchronous call from JS is parked in its place until the op JS sent after it is applied (RustCall::Post), and what the ops before that one post while the core applies them goes before it. So a call a task posts after the synchronous call runs after it, and one an op JS sent before the call posts runs before it. The queue runs up to the first place not released yet; a place is released whichever way its op goes (applied, or dropped unapplied: [ParkedPost]), so no lost op stalls it.

Implementations§

Source§

impl Posts

Source

pub fn new() -> Self

An empty queue.

Source

pub fn set_notify(&self, notify: Arc<dyn Fn() + Send + Sync>)

Calls notify when a call becomes runnable (it wakes the engine).

Source

pub fn close(&self)

No JS runs any more (the VM stopped or went): the queued calls are dropped, and so are those posted later (their replies say so).

Source

pub fn has_calls(&self) -> bool

Whether a call can run now.

Trait Implementations§

Source§

impl Clone for Posts

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Posts

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Posts

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Posts

§

impl !Send for Posts

§

impl !Sync for Posts

§

impl !UnwindSafe for Posts

§

impl Forget for Posts

§

impl Freeze for Posts
where *const RcInner<PostsInner> is !null: Freeze, PhantomData<RcInner<PostsInner>>: Freeze,

§

impl Move for Posts

§

impl Unpin for Posts
where Rc<PostsInner>: Unpin,

§

impl UnsafeUnpin for Posts
where *const RcInner<PostsInner> is !null: UnsafeUnpin, PhantomData<RcInner<PostsInner>>: UnsafeUnpin,

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<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 = !

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

fn try_from(value: U) -> Result<T, !>

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.