mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Implement discarding Document objects to reclaim space.
This commit is contained in:
parent
955e2851bf
commit
78c87ea8d7
8 changed files with 301 additions and 218 deletions
|
@ -228,18 +228,18 @@ impl OneshotTimers {
|
|||
}
|
||||
|
||||
pub fn suspend(&self) {
|
||||
assert!(self.suspended_since.get().is_none());
|
||||
// Suspend is idempotent: do nothing if the timers are already suspended.
|
||||
if self.suspended_since.get().is_some() { return; }
|
||||
|
||||
self.suspended_since.set(Some(precise_time_ms()));
|
||||
self.invalidate_expected_event_id();
|
||||
}
|
||||
|
||||
pub fn resume(&self) {
|
||||
assert!(self.suspended_since.get().is_some());
|
||||
|
||||
// Suspend is idempotent: do nothing if the timers are already suspended.
|
||||
let additional_offset = match self.suspended_since.get() {
|
||||
Some(suspended_since) => precise_time_ms() - suspended_since,
|
||||
None => panic!("Timers are not suspended.")
|
||||
None => return,
|
||||
};
|
||||
|
||||
self.suspension_offset.set(self.suspension_offset.get() + additional_offset);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue