mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-02 05:17:31 +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;
|
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;
|
virtual Mutex& GetMutex() = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -364,18 +378,26 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
void HandleLowMemory() {
|
void HandleLowMemory() {
|
||||||
AutoLock lock(GetMutex());
|
{
|
||||||
AgeAllGenerationsLocked(lock);
|
AutoLock lock(GetMutex());
|
||||||
|
AgeAllGenerationsLocked(lock);
|
||||||
|
NotifyHandlerEndLocked(lock);
|
||||||
|
}
|
||||||
|
NotifyHandlerEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleTimeout() {
|
void HandleTimeout() {
|
||||||
AutoLock lock(GetMutex());
|
{
|
||||||
AgeOneGenerationLocked(lock);
|
AutoLock lock(GetMutex());
|
||||||
// Cancel the timer if we have no objects to track
|
AgeOneGenerationLocked(lock);
|
||||||
if (IsEmptyLocked(lock)) {
|
// Cancel the timer if we have no objects to track
|
||||||
mTimer->Cancel();
|
if (IsEmptyLocked(lock)) {
|
||||||
mTimer = nullptr;
|
mTimer->Cancel();
|
||||||
|
mTimer = nullptr;
|
||||||
|
}
|
||||||
|
NotifyHandlerEndLocked(lock);
|
||||||
}
|
}
|
||||||
|
NotifyHandlerEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TimerCallback(nsITimer* aTimer, void* aThis)
|
static void TimerCallback(nsITimer* aTimer, void* aThis)
|
||||||
|
|
@ -449,6 +471,14 @@ class nsExpirationTracker : protected ::detail::SingleThreadedExpirationTracker<
|
||||||
NotifyExpired(aObject);
|
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:
|
protected:
|
||||||
virtual void NotifyExpired(T* aObj) = 0;
|
virtual void NotifyExpired(T* aObj) = 0;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue