pub(crate) struct OneshotTimers {
global_scope: Dom<GlobalScope>,
js_timers: JsTimers,
next_timer_handle: Cell<OneshotTimerHandle>,
timers: DomRefCell<VecDeque<OneshotTimer>>,
suspended_since: Cell<Option<Instant>>,
suspension_offset: Cell<Duration>,
expected_event_id: Cell<TimerEventId>,
map_of_active_timers: DomRefCell<FxHashMap<i32, Instant>>,
runsteps_queues: DomRefCell<FxHashMap<DOMString, Vec<OrderingEntry>>>,
next_runsteps_key: Cell<i32>,
runsteps_start_seq: Cell<u64>,
}Fields§
§global_scope: Dom<GlobalScope>§js_timers: JsTimers§next_timer_handle: Cell<OneshotTimerHandle>§timers: DomRefCell<VecDeque<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.
map_of_active_timers: DomRefCell<FxHashMap<i32, Instant>>https://html.spec.whatwg.org/multipage/#map-of-active-timers TODO this should also be used for the other timers as per <html.spec.whatwg.org/multipage/#map-of-settimeout-and-setinterval-ids>Z.
runsteps_queues: DomRefCell<FxHashMap<DOMString, Vec<OrderingEntry>>>https://html.spec.whatwg.org/multipage/#run-steps-after-a-timeout Step 4.2 Wait until any invocations of this algorithm that had the same global and orderingIdentifier, that started before this one, and whose milliseconds is less than or equal to this one’s, have completed.
next_runsteps_key: Cell<i32><html.spec.whatwg.org/multipage/#timers:unique-internal-value-5>
runsteps_start_seq: Cell<u64>https://html.spec.whatwg.org/multipage/#run-steps-after-a-timeout Start order sequence to break ties for Step 4.2.
Implementations§
Source§impl OneshotTimers
impl OneshotTimers
pub(crate) fn new(global_scope: &GlobalScope) -> OneshotTimers
Sourcepub(crate) fn now_for_runsteps(&self) -> Instant
pub(crate) fn now_for_runsteps(&self) -> Instant
Sourcepub(crate) fn fresh_runsteps_key(&self) -> i32
pub(crate) fn fresh_runsteps_key(&self) -> i32
https://html.spec.whatwg.org/multipage/#run-steps-after-a-timeout Step 1. Let timerKey be a new unique internal value.
Sourcepub(crate) fn runsteps_set_active(&self, timer_key: i32, deadline: Instant)
pub(crate) fn runsteps_set_active(&self, timer_key: i32, deadline: Instant)
https://html.spec.whatwg.org/multipage/#run-steps-after-a-timeout Step 3. Set global’s map of active timers[timerKey] to startTime plus milliseconds.
Sourcefn runsteps_enqueue_sorted(
&self,
ordering_id: &DOMString,
handle: OneshotTimerHandle,
milliseconds: u64,
)
fn runsteps_enqueue_sorted( &self, ordering_id: &DOMString, handle: OneshotTimerHandle, milliseconds: u64, )
https://html.spec.whatwg.org/multipage/#run-steps-after-a-timeout Helper for Step 4.2: maintain per-ordering sorted queue by (milliseconds, startSeq, handle).
pub(crate) fn schedule_callback( &self, callback: OneshotTimerCallback, duration: Duration, source: TimerSource, ) -> OneshotTimerHandle
pub(crate) fn unschedule_callback(&self, handle: OneshotTimerHandle)
fn is_next_timer(&self, handle: OneshotTimerHandle) -> bool
Sourcepub(crate) fn fire_timer(
&self,
id: TimerEventId,
global: &GlobalScope,
can_gc: CanGc,
)
pub(crate) fn fire_timer( &self, id: TimerEventId, global: &GlobalScope, can_gc: CanGc, )
fn base_time(&self) -> Instant
pub(crate) fn slow_down(&self)
pub(crate) fn speed_up(&self)
pub(crate) fn suspend(&self)
pub(crate) fn resume(&self)
Sourcefn schedule_timer_call(&self)
fn schedule_timer_call(&self)
fn invalidate_expected_event_id(&self) -> TimerEventId
pub(crate) fn set_timeout_or_interval( &self, global: &GlobalScope, callback: TimerCallback, arguments: Vec<HandleValue<'_>>, timeout: Duration, is_interval: IsInterval, source: TimerSource, can_gc: CanGc, ) -> Fallible<i32>
pub(crate) 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
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
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>
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>
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>
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 more