pub struct CommandQueue {
pub commands: Mutex<Vec<ScriptCommand>>,
/* private fields */
}Expand description
Thread-safe queue of pending ScriptCommands, accessible from Lua callbacks.
Lua callbacks cannot mutate the World directly, so they push commands here;
the engine later drains and applies them at a controlled point in the frame.
Fields§
§commands: Mutex<Vec<ScriptCommand>>Pending commands, guarded by a mutex so Lua callbacks can push concurrently.
Implementations§
Source§impl CommandQueue
impl CommandQueue
Sourcepub fn push(&self, cmd: ScriptCommand)
pub fn push(&self, cmd: ScriptCommand)
Appends a command to the queue, unless it carries a non-finite number.
Dropped rather than clamped: a clamped force is a wrong answer the frame accepts silently, while a dropped one is a no-op with a log line and a counter behind it. A script that produced NaN has a bug, and the useful thing to do is say so, not to guess what it meant.
Sourcepub fn rejected_count(&self) -> u64
pub fn rejected_count(&self) -> u64
How many commands have been refused for carrying NaN or infinity, since this queue was created.
Sourcepub fn drain(&self) -> Vec<ScriptCommand>
pub fn drain(&self) -> Vec<ScriptCommand>
Removes and returns all currently queued commands, leaving the queue empty.
Trait Implementations§
Source§impl Debug for CommandQueue
impl Debug for CommandQueue
Source§impl Default for CommandQueue
impl Default for CommandQueue
Source§fn default() -> CommandQueue
fn default() -> CommandQueue
Auto Trait Implementations§
impl !Freeze for CommandQueue
impl RefUnwindSafe for CommandQueue
impl Send for CommandQueue
impl Sync for CommandQueue
impl Unpin for CommandQueue
impl UnsafeUnpin for CommandQueue
impl UnwindSafe for CommandQueue
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more