pub trait IRenderTimer: Send + Sync {
// Required methods
fn tick(&self) -> Option<RenderTimerTick>;
fn set_tick(&self, value: Option<RenderTimerTick>);
fn runs_in_background(&self) -> bool;
// Provided method
fn request_tick_out_of_turn(&self) { ... }
}Expand description
Defines the interface implemented by an application render timer.
Required Methods§
Sourcefn tick(&self) -> Option<RenderTimerTick>
fn tick(&self) -> Option<RenderTimerTick>
Gets the callback to be invoked when the timer ticks.
Sourcefn set_tick(&self, value: Option<RenderTimerTick>)
fn set_tick(&self, value: Option<RenderTimerTick>)
Sets the callback to be invoked when the timer ticks.
This can be called from any thread, but it’s guaranteed that it’s not
called concurrently (i. e. the render loop always does it under a
lock). Setting the value to None suggests the timer to stop ticking,
however the timer is allowed to produce ticks on the previously set
value as long as it stops doing so.
The callback can be invoked on any thread. Implementations must not invoke it synchronously from this method: the render loop calls it while holding a lock that the callback takes.
Sourcefn runs_in_background(&self) -> bool
fn runs_in_background(&self) -> bool
Indicates if the timer ticks on a non-UI thread.
Provided Methods§
Sourcefn request_tick_out_of_turn(&self)
fn request_tick_out_of_turn(&self)
Asks for a tick out of turn: as soon as the thread that ticks can produce one, without waiting for the next period of the timer (the next frame of a display). Not from upstream.
Called by a thread that is about to block until a frame has been rendered. A timer whose next tick may be far away, or may depend on the caller returning to its event loop, invokes the callback it was given once on the thread it ticks on; it must not invoke it on the calling thread, and does nothing while no callback is set. The default does nothing: the caller then waits for the next tick.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".