4040namespace yup
4141{
4242
43- static SpinLock deletedAtShutdownLock; // use a spin lock because it can be statically initialised
43+ static SpinLock& getDeletedAtShutdownSpinLock ()
44+ {
45+ static SpinLock deletedAtShutdownLock;
46+ return deletedAtShutdownLock;
47+ }
4448
4549static Array<DeletedAtShutdown*>& getDeletedAtShutdownObjects ()
4650{
@@ -50,13 +54,13 @@ static Array<DeletedAtShutdown*>& getDeletedAtShutdownObjects()
5054
5155DeletedAtShutdown::DeletedAtShutdown ()
5256{
53- const SpinLock::ScopedLockType sl (deletedAtShutdownLock );
57+ const SpinLock::ScopedLockType sl (getDeletedAtShutdownSpinLock () );
5458 getDeletedAtShutdownObjects ().add (this );
5559}
5660
5761DeletedAtShutdown::~DeletedAtShutdown ()
5862{
59- const SpinLock::ScopedLockType sl (deletedAtShutdownLock );
63+ const SpinLock::ScopedLockType sl (getDeletedAtShutdownSpinLock () );
6064 getDeletedAtShutdownObjects ().removeFirstMatchingValue (this );
6165}
6266
@@ -71,7 +75,7 @@ void DeletedAtShutdown::deleteAll()
7175 Array<DeletedAtShutdown*> localCopy;
7276
7377 {
74- const SpinLock::ScopedLockType sl (deletedAtShutdownLock );
78+ const SpinLock::ScopedLockType sl (getDeletedAtShutdownSpinLock () );
7579 localCopy = getDeletedAtShutdownObjects ();
7680 }
7781
@@ -83,7 +87,7 @@ void DeletedAtShutdown::deleteAll()
8387
8488 // double-check that it's not already been deleted during another object's destructor.
8589 {
86- const SpinLock::ScopedLockType sl (deletedAtShutdownLock );
90+ const SpinLock::ScopedLockType sl (getDeletedAtShutdownSpinLock () );
8791
8892 if (! getDeletedAtShutdownObjects ().contains (deletee))
8993 deletee = nullptr ;
0 commit comments