mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 743786 - Add IsMainThread assertions to ClearOnShutdown. r=bmsedberg
This commit is contained in:
parent
51d4c74935
commit
da57cc811b
@ -41,6 +41,7 @@
|
||||
#define mozilla_ClearOnShutdown_h
|
||||
|
||||
#include "mozilla/LinkedList.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
/*
|
||||
* This header exports one public method in the mozilla namespace:
|
||||
@ -56,6 +57,10 @@
|
||||
*
|
||||
* There is no way to undo a call to ClearOnShutdown, so you can call it only
|
||||
* on smart pointers which you know will live until the program shuts down.
|
||||
*
|
||||
* ClearOnShutdown is currently main-thread only because we don't want to
|
||||
* accidentally free an object from a different thread than the one it was
|
||||
* created on.
|
||||
*/
|
||||
|
||||
namespace mozilla {
|
||||
@ -96,6 +101,8 @@ inline void ClearOnShutdown(SmartPtr *aPtr)
|
||||
{
|
||||
using namespace ClearOnShutdown_Internal;
|
||||
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
MOZ_ASSERT(!sHasShutDown);
|
||||
ShutdownObserver *observer = new PointerClearer<SmartPtr>(aPtr);
|
||||
sShutdownObservers.insertBack(observer);
|
||||
@ -107,6 +114,8 @@ inline void KillClearOnShutdown()
|
||||
{
|
||||
using namespace ClearOnShutdown_Internal;
|
||||
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ShutdownObserver *observer;
|
||||
while ((observer = sShutdownObservers.popFirst())) {
|
||||
observer->Shutdown();
|
||||
|
Loading…
Reference in New Issue
Block a user