phoenix-firestorm/indra/llwindow
Nat Goodspeed b2913b7cf1 DRTVWR-494: Defend LLInstanceTracker against multi-thread usage.
The previous implementation went to some effort to crash if anyone attempted
to create or destroy an LLInstanceTracker subclass instance during traversal.
That restriction is manageable within a single thread, but becomes unworkable
if it's possible that a given subclass might be used on more than one thread.

Remove LLInstanceTracker::instance_iter, beginInstances(), endInstances(),
also key_iter, beginKeys() and endKeys(). Instead, introduce key_snapshot()
and instance_snapshot(), the only means of iterating over LLInstanceTracker
instances. (These are intended to resemble functions, but in fact the current
implementation simply presents the classes.) Iterating over a captured
snapshot defends against container modifications during traversal. The term
'snapshot' reminds the coder that a new instance created during traversal will
not be considered. To defend against instance deletion during traversal, a
snapshot stores std::weak_ptrs which it lazily dereferences, skipping on the
fly any that have expired.

Dereferencing instance_snapshot::iterator gets you a reference rather than a
pointer. Because some use cases want to delete all existing instances, add an
instance_snapshot::deleteAll() method that extracts the pointer. Those cases
used to require explicitly copying instance pointers into a separate
container; instance_snapshot() now takes care of that. It remains the caller's
responsibility to ensure that all instances of that LLInstanceTracker subclass
were allocated on the heap.

Replace unkeyed static LLInstanceTracker::getInstance(T*) -- which returned
nullptr if that instance had been destroyed -- with new getWeak() method
returning std::weak_ptr<T>. Caller must detect expiration of that weak_ptr.

Adjust tests accordingly.

Use of std::weak_ptr to detect expired instances requires engaging
std::shared_ptr in the constructor. We now store shared_ptrs in the static
containers (std::map for keyed, std::set for unkeyed).

Make LLInstanceTrackerBase a template parameterized on the type of the static
data it manages. For that reason, hoist static data class declarations out of
the class definitions to an LLInstanceTrackerStuff namespace.

Remove the static atomic sIterationNestDepth and its methods incrementDepth(),
decrementDepth() and getDepth(), since they were used only to forbid creation
and destruction during traversal.

Add a std::mutex to static data. Introduce an internal LockStatic class that
locks the mutex while providing a pointer to static data, making that the only
way to access the static data.

The LLINSTANCETRACKER_DTOR_NOEXCEPT macro goes away because we no longer
expect ~LLInstanceTracker() to throw an exception in test programs.
That affects LLTrace::StatBase as well as LLInstanceTracker itself.

Adapt consumers to the new LLInstanceTracker API.
2019-12-02 14:39:24 -05:00
..
GL
CMakeLists.txt
llappdelegate-objc.h SL-11432 FIXED [OSX] Avatar is spinning when pressing Alt+D+Command and then releasing D key 2019-06-20 15:41:27 +03:00
llcursortypes.cpp
llcursortypes.h
lldragdropwin32.cpp
lldragdropwin32.h
lldxhardware.cpp MAINT-2060 Fixed Double Freeze when clicking on Help>About Second Life 2017-05-19 20:28:59 +03:00
lldxhardware.h MAINT-2060 Fixed Double Freeze when clicking on Help>About Second Life 2017-05-19 20:28:59 +03:00
llkeyboard.cpp
llkeyboard.h
llkeyboardheadless.cpp
llkeyboardheadless.h
llkeyboardmacosx.cpp
llkeyboardmacosx.h
llkeyboardsdl.cpp
llkeyboardsdl.h
llkeyboardwin32.cpp
llkeyboardwin32.h
llmousehandler.cpp
llmousehandler.h
llopenglview-objc.h
llopenglview-objc.mm SL-11432 FIXED [OSX] Avatar is spinning when pressing Alt+D+Command and then releasing D key 2019-06-20 15:41:27 +03:00
llpreeditor.h
llwindow.cpp DRTVWR-494: Defend LLInstanceTracker against multi-thread usage. 2019-12-02 14:39:24 -05:00
llwindow.h - remove getDeviceScaleFactor() and replace it to getSystemUISize() according Ansariel note 2019-01-14 19:07:00 +02:00
llwindowcallbacks.cpp SL-9774 [Render] dragging active Second Life session to second monitor zooms in making viewer unusable 2018-10-23 19:24:03 +03:00
llwindowcallbacks.h SL-9774 [Render] dragging active Second Life session to second monitor zooms in making viewer unusable 2018-10-23 19:24:03 +03:00
llwindowheadless.cpp
llwindowheadless.h
llwindowmacosx-objc.h Return CGPoint and CGSize by value, not const ref to temporary. 2019-04-25 15:11:55 -04:00
llwindowmacosx-objc.mm Return CGPoint and CGSize by value, not const ref to temporary. 2019-04-25 15:11:55 -04:00
llwindowmacosx.cpp SL-11178 FIXED [mac] Viewer crashes if another app gets focus before viewer window is created 2019-05-16 12:14:07 +03:00
llwindowmacosx.h - remove getDeviceScaleFactor() and replace it to getSystemUISize() according Ansariel note 2019-01-14 19:07:00 +02:00
llwindowmesaheadless.cpp
llwindowmesaheadless.h
llwindowsdl.cpp
llwindowsdl.h
llwindowwin32.cpp Merged in lindenlab/viewer-release 2019-08-13 21:54:23 +03:00
llwindowwin32.h Fix issue where gamma was being corrupted on windows with night light enabled 2019-02-08 19:26:28 -08:00