Struct script::timers::OneshotTimers
source · pub struct OneshotTimers {
js_timers: JsTimers,
timer_event_chan: DomRefCell<Option<IpcSender<TimerEvent>>>,
scheduler_chan: IpcSender<TimerSchedulerMsg>,
next_timer_handle: Cell<OneshotTimerHandle>,
timers: DomRefCell<Vec<OneshotTimer>>,
suspended_since: Cell<Option<MsDuration>>,
suspension_offset: Cell<MsDuration>,
expected_event_id: Cell<TimerEventId>,
}
Fields§
§js_timers: JsTimers
§timer_event_chan: DomRefCell<Option<IpcSender<TimerEvent>>>
The sender, to be cloned for each timer, on which the timer scheduler in the constellation can send an event when the timer is due.
scheduler_chan: IpcSender<TimerSchedulerMsg>
The sender to the timer scheduler in the constellation.
next_timer_handle: Cell<OneshotTimerHandle>
§timers: DomRefCell<Vec<OneshotTimer>>
§suspended_since: Cell<Option<MsDuration>>
§suspension_offset: Cell<MsDuration>
Initially 0, increased whenever the associated document is reactivated by the amount of ms the document was inactive. The current time can be offset back by this amount for a coherent time across document activations.
expected_event_id: Cell<TimerEventId>
Calls to fire_timer
with a different argument than this get ignored.
They were previously scheduled and got invalidated when
- timers were suspended,
- the timer it was scheduled for got canceled or
- a timer was added with an earlier callback time. In this case the original timer is rescheduled when it is the next one to get called.
Implementations§
source§impl OneshotTimers
impl OneshotTimers
pub fn new(scheduler_chan: IpcSender<TimerSchedulerMsg>) -> OneshotTimers
pub fn setup_scheduling(&self, timer_event_chan: IpcSender<TimerEvent>)
pub fn schedule_callback(
&self,
callback: OneshotTimerCallback,
duration: MsDuration,
source: TimerSource
) -> OneshotTimerHandle
pub fn unschedule_callback(&self, handle: OneshotTimerHandle)
fn is_next_timer(&self, handle: OneshotTimerHandle) -> bool
pub fn fire_timer(&self, id: TimerEventId, global: &GlobalScope)
fn base_time(&self) -> MsDuration
pub fn slow_down(&self)
pub fn speed_up(&self)
pub fn suspend(&self)
pub fn resume(&self)
fn schedule_timer_call(&self)
fn invalidate_expected_event_id(&self) -> TimerEventId
pub fn set_timeout_or_interval(
&self,
global: &GlobalScope,
callback: TimerCallback,
arguments: Vec<HandleValue<'_>>,
timeout: i32,
is_interval: IsInterval,
source: TimerSource
) -> i32
pub fn clear_timeout_or_interval(&self, global: &GlobalScope, handle: i32)
Trait Implementations§
source§impl JSTraceable for OneshotTimers
impl JSTraceable for OneshotTimers
source§impl MallocSizeOf for OneshotTimers
impl MallocSizeOf for OneshotTimers
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but
not the space taken up by the value itself.
Auto Trait Implementations§
impl !RefUnwindSafe for OneshotTimers
impl !Send for OneshotTimers
impl !Sync for OneshotTimers
impl Unpin for OneshotTimers
impl !UnwindSafe for OneshotTimers
Blanket Implementations§
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> 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> MaybeBoxed<Box<T, Global>> for T
impl<T> MaybeBoxed<Box<T, Global>> for T
source§fn maybe_boxed(self) -> Box<T, Global>
fn maybe_boxed(self) -> Box<T, Global>
Convert
source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert