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<Instant>>,
suspension_offset: Cell<Duration>,
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<Instant>>
§suspension_offset: Cell<Duration>
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: Duration, 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, can_gc: CanGc)
fn base_time(&self) -> Instant
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: Duration, is_interval: IsInterval, source: TimerSource, ) -> i32
pub fn clear_timeout_or_interval(&self, global: &GlobalScope, handle: i32)
Trait Implementations§
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 !Freeze for OneshotTimers
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
Creates a filterable data provider with the given name for debugging. Read more
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> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
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