mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1851045 - Part 5: Eliminate nsThreadManager's static destructor, r=emilio
This both reduces the number of registered static destructors, and avoids the assertion in the LinkedList destructor without depending on a StaticAutoPointer (which requires an allocation & additional indirection) by using the new NeverDestroyed type from part 4. Differential Revision: https://phabricator.services.mozilla.com/D189249
This commit is contained in:
parent
9411a9ed15
commit
f6b6fca22f
@ -20,6 +20,7 @@
|
||||
#include "mozilla/EventQueue.h"
|
||||
#include "mozilla/InputTaskManager.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/NeverDestroyed.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/ProfilerMarkers.h"
|
||||
#include "mozilla/SpinEventLoopUntil.h"
|
||||
@ -257,8 +258,8 @@ NS_IMPL_CI_INTERFACE_GETTER(nsThreadManager, nsIThreadManager)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/*static*/ nsThreadManager& nsThreadManager::get() {
|
||||
static nsThreadManager sInstance;
|
||||
return sInstance;
|
||||
static NeverDestroyed<nsThreadManager> sInstance;
|
||||
return *sInstance;
|
||||
}
|
||||
|
||||
nsThreadManager::nsThreadManager()
|
||||
|
@ -18,6 +18,9 @@ namespace mozilla {
|
||||
class IdleTaskManager;
|
||||
class SynchronizedEventQueue;
|
||||
class TaskQueue;
|
||||
|
||||
template <typename T>
|
||||
class NeverDestroyed;
|
||||
} // namespace mozilla
|
||||
|
||||
class BackgroundEventTarget;
|
||||
@ -103,6 +106,8 @@ class nsThreadManager : public nsIThreadManager {
|
||||
}
|
||||
|
||||
private:
|
||||
friend class mozilla::NeverDestroyed<nsThreadManager>;
|
||||
|
||||
nsThreadManager();
|
||||
|
||||
nsresult SpinEventLoopUntilInternal(
|
||||
|
Loading…
Reference in New Issue
Block a user