mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 11:57:32 +09:00
Issue #2218 - Part 1: Add nsExpirationTracker::NotifyEndTransaction(Locked) callbacks for subclasses to know when an aging iteration is complete
Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1389479
This commit is contained in:
parent
62e2fbc4e9
commit
fa787f4a6a
1 changed files with 38 additions and 8 deletions
|
|
@ -322,6 +322,20 @@ protected:
|
|||
*/
|
||||
virtual void NotifyExpiredLocked(T*, const AutoLock&) = 0;
|
||||
|
||||
/**
|
||||
* This may be overridden to perform any post-aging work that needs to be
|
||||
* done while still holding the lock. It will be called once after each timer
|
||||
* event, and each low memory event has been handled.
|
||||
*/
|
||||
virtual void NotifyHandlerEndLocked(const AutoLock&) { };
|
||||
|
||||
/**
|
||||
* This may be overridden to perform any post-aging work that needs to be
|
||||
* done outside the lock. It will be called once after each
|
||||
* NotifyEndTransactionLocked call.
|
||||
*/
|
||||
virtual void NotifyHandlerEnd() { };
|
||||
|
||||
virtual Mutex& GetMutex() = 0;
|
||||
|
||||
private:
|
||||
|
|
@ -364,11 +378,16 @@ private:
|
|||
};
|
||||
|
||||
void HandleLowMemory() {
|
||||
{
|
||||
AutoLock lock(GetMutex());
|
||||
AgeAllGenerationsLocked(lock);
|
||||
NotifyHandlerEndLocked(lock);
|
||||
}
|
||||
NotifyHandlerEnd();
|
||||
}
|
||||
|
||||
void HandleTimeout() {
|
||||
{
|
||||
AutoLock lock(GetMutex());
|
||||
AgeOneGenerationLocked(lock);
|
||||
// Cancel the timer if we have no objects to track
|
||||
|
|
@ -376,6 +395,9 @@ private:
|
|||
mTimer->Cancel();
|
||||
mTimer = nullptr;
|
||||
}
|
||||
NotifyHandlerEndLocked(lock);
|
||||
}
|
||||
NotifyHandlerEnd();
|
||||
}
|
||||
|
||||
static void TimerCallback(nsITimer* aTimer, void* aThis)
|
||||
|
|
@ -449,6 +471,14 @@ class nsExpirationTracker : protected ::detail::SingleThreadedExpirationTracker<
|
|||
NotifyExpired(aObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Since there are no users of these callbacks in the single threaded case,
|
||||
* we mark them as final with the hope that the compiler can optimize the
|
||||
* method calls out entirely.
|
||||
*/
|
||||
void NotifyHandlerEndLocked(const AutoLock&) final override { }
|
||||
void NotifyHandlerEnd() final override { }
|
||||
|
||||
protected:
|
||||
virtual void NotifyExpired(T* aObj) = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue