pub struct Clock(/* private fields */);Implementations§
Source§impl Clock
impl Clock
Sourcepub fn new(tb: Option<Box<NonBlockTickBridge>>) -> Option<Self>
pub fn new(tb: Option<Box<NonBlockTickBridge>>) -> Option<Self>
Creates a new Clock instance collocated with application thread.
It is recommended to create collocated Clock for message-based applications,
especially when each application instance is anchored to a dedicated thread.
This ensures that the clock is synchronized with the application thread,
allowing all relevant timers to be handled within the same thread for optimal performance.
Panics if too many instances are created.
The instance will persist until the process is closed.
Implements the Copy trait, maintaining only one real instance.
§Arguments
tb: Tick bridge, a proxy to pass the tick to the clock instance when the clock is collocated with application thread, otherwise, None.
§Returns
The newly created Clock instance.
Sourcepub fn take_thread_handle() -> Option<JoinHandle<()>>
pub fn take_thread_handle() -> Option<JoinHandle<()>>
Takes the thread handle of the Timer module for graceful shutdown.
§Returns
The thread handle for the Timer module shutdown.
Sourcepub fn terminate_for_process_exit()
pub fn terminate_for_process_exit()
Terminates the Timer module.
Sourcepub fn on_tick(self, tick: Tick) -> AnyResult<()>
pub fn on_tick(self, tick: Tick) -> AnyResult<()>
In case of clock instance is collocated with application thread, at the end of the path of relaying Tick, the application shall invoke clock.on_tick() to send the event to relevant instance. See the sample for TickBridge.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Clock
impl RefUnwindSafe for Clock
impl Send for Clock
impl Sync for Clock
impl Unpin for Clock
impl UnwindSafe for Clock
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)