Skip to main content

BrowserRenderTimer

Struct BrowserRenderTimer 

Source
pub struct BrowserRenderTimer { /* private fields */ }
Expand description

A render timer that ticks with the animation frames of the thread it is started on: the page, or the worker of a render thread.

Implementations§

Source§

impl BrowserRenderTimer

Source

pub fn new(is_background: bool) -> Arc<Self> ⓘ

Creates the timer. is_background tells whether its ticks arrive on a thread other than the UI thread: such a timer is started by the thread that renders, with start_on_this_thread.

Source

pub fn start_on_this_thread(&self)

Starts following the animation frames on the current thread. Does nothing when the timer is started already.

The thread has to live for as long as the timer is used: its frames arrive at the event loop of its worker, and so does a tick out of turn.

Trait Implementations§

Source§

impl IRenderTimer for BrowserRenderTimer

Source§

fn request_tick_out_of_turn(&self)

Queues one tick for the thread the timer was started on, which runs it from its event loop without waiting for its next animation frame. Requests made before that tick has started are one request. The timestamp of the tick is read from the clock of the animation frames of that thread.

A request made to a background timer that is not started yet is kept: the thread that starts the timer ticks once when it does. (The thread of the page asks before it waits for a frame, and the render thread it started a moment ago may not have got that far.)

Does nothing when the caller is the thread that ticks (it cannot be waiting for itself), while no callback is set, and in a build without threads.

Source§

fn tick(&self) -> Option<RenderTimerTick>

Gets the callback to be invoked when the timer ticks.
Source§

fn set_tick(&self, value: Option<RenderTimerTick>)

Sets the callback to be invoked when the timer ticks. Read more
Source§

fn runs_in_background(&self) -> bool

Indicates if the timer ticks on a non-UI thread.

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> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). 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 = !

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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more