Struct SingletonThread

Source
pub struct SingletonThread { /* private fields */ }

Implementations§

Source§

impl SingletonThread

Source

pub fn new(mainFn: impl Fn() + Send + Sync + 'static) -> Self

create a new singletonThread

Source

pub fn newFiltered( mainFn: impl Fn() + Send + Sync + 'static, filterFn: impl Fn() -> bool + Send + Sync + 'static, ) -> Self

create a new singletonThread with a filter. filter is run each time, after testing if the thread is running or not, filter must return true if the thread can be launched, or false if not

Source

pub fn thread_launch(&mut self) -> bool

try to launch a new run, check if not running AND the filter function return true return if the thread have been launched

Source

pub fn thread_launch_delayabe(&mut self)

try to launch a new run, check if not running, AND the filter function returns true if it cannot be launched immediately, mark the class to run another time after the current one. can only mark one time.

Source

pub fn duration_set(&mut self, duration: Duration)

minimum duration before another run can occur, default 1ns

Source

pub fn duration_setFPS(&mut self, fps: u8)

minimum duration before another run can occur from frame per second (60 fps = 16.666 ms), minimum 1 fps (1 ms)

Source

pub fn loop_set(&mut self, canLoop: bool)

define if the thread auto relaunch himself (technically it just use the same thread) set to false if you want to stop a looped thread that running.

Source

pub fn thread_setName(&mut self, name: impl Into<String>)

set the name of the thread. the name is updated only if the thread launch is completely relaunched (no change when a loop ends)

Source

pub fn thread_getName(&mut self) -> &Option<String>

get the name of the thread

Source

pub fn wait(&mut self) -> Result<()>

set the thread to stop looping wait the thread is stopped

Auto Trait Implementations§

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