phoenix-firestorm/indra/llui
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
..
tests
CMakeLists.txt
llaccordionctrl.cpp
llaccordionctrl.h
llaccordionctrltab.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llaccordionctrltab.h
llbadge.cpp
llbadge.h
llbadgeholder.cpp
llbadgeholder.h
llbadgeowner.cpp
llbadgeowner.h
llbutton.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llbutton.h
llcallbackmap.h
llchat.h
llchatentry.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llchatentry.h
llcheckboxctrl.cpp
llcheckboxctrl.h
llclipboard.cpp
llclipboard.h
llcombobox.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llcombobox.h
llcommandmanager.cpp
llcommandmanager.h
llconsole.cpp DRTVWR-494: Defend LLInstanceTracker against multi-thread usage. 2019-12-02 14:39:24 -05:00
llconsole.h DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llcontainerview.cpp
llcontainerview.h
llctrlselectioninterface.cpp
llctrlselectioninterface.h
lldockablefloater.cpp
lldockablefloater.h
lldockcontrol.cpp
lldockcontrol.h
lldraghandle.cpp
lldraghandle.h
lleditmenuhandler.cpp
lleditmenuhandler.h
llf32uictrl.cpp
llf32uictrl.h
llfiltereditor.cpp
llfiltereditor.h
llflashtimer.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llflashtimer.h
llflatlistview.cpp
llflatlistview.h
llfloater.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llfloater.h
llfloaterreg.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llfloaterreg.h
llfloaterreglistener.cpp
llfloaterreglistener.h
llflyoutbutton.cpp
llflyoutbutton.h
llfocusmgr.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llfocusmgr.h
llfolderview.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llfolderview.h
llfolderviewitem.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llfolderviewitem.h
llfolderviewmodel.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llfolderviewmodel.h
llfunctorregistry.h
llhelp.h
lliconctrl.cpp
lliconctrl.h
llkeywords.cpp
llkeywords.h
lllayoutstack.cpp DRTVWR-494: Defend LLInstanceTracker against multi-thread usage. 2019-12-02 14:39:24 -05:00
lllayoutstack.h
lllazyvalue.h
lllineeditor.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
lllineeditor.h SL-10890 Ban duration edit field shows value with a left shift if a large value was set 2019-04-05 22:42:04 +03:00
llloadingindicator.cpp
llloadingindicator.h
lllocalcliprect.cpp
lllocalcliprect.h
llmenubutton.cpp
llmenubutton.h
llmenugl.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llmenugl.h
llmodaldialog.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llmodaldialog.h
llmultifloater.cpp
llmultifloater.h
llmultislider.cpp
llmultislider.h
llmultisliderctrl.cpp
llmultisliderctrl.h
llnotificationptr.h
llnotifications.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llnotifications.h
llnotificationslistener.cpp DRTVWR-494: Defend LLInstanceTracker against multi-thread usage. 2019-12-02 14:39:24 -05:00
llnotificationslistener.h
llnotificationsutil.cpp
llnotificationsutil.h
llnotificationtemplate.h
llnotificationvisibilityrule.h
llpanel.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llpanel.h
llprogressbar.cpp
llprogressbar.h
llradiogroup.cpp
llradiogroup.h
llresizebar.cpp
llresizebar.h
llresizehandle.cpp
llresizehandle.h
llresmgr.cpp
llresmgr.h
llrngwriter.cpp
llrngwriter.h
llscrollbar.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llscrollbar.h
llscrollcontainer.cpp
llscrollcontainer.h
llscrollingpanellist.cpp
llscrollingpanellist.h
llscrolllistcell.cpp
llscrolllistcell.h
llscrolllistcolumn.cpp
llscrolllistcolumn.h
llscrolllistctrl.cpp
llscrolllistctrl.h
llscrolllistitem.cpp
llscrolllistitem.h
llsearchablecontrol.h
llsearcheditor.cpp
llsearcheditor.h
llslider.cpp
llslider.h
llsliderctrl.cpp
llsliderctrl.h
llspellcheck.cpp DRTVWR-493 LLSpellcheck doesn't need separate init 2019-06-27 22:14:52 +03:00
llspellcheck.h DRTVWR-493 LLSpellcheck doesn't need separate init 2019-06-27 22:14:52 +03:00
llspellcheckmenuhandler.h
llspinctrl.cpp SL-10890 Ban duration edit field shows value with a left shift if a large value was set 2019-04-05 22:42:04 +03:00
llspinctrl.h
llstatbar.cpp
llstatbar.h
llstatgraph.cpp
llstatgraph.h
llstatview.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llstatview.h
llstyle.cpp
llstyle.h
lltabcontainer.cpp SL-10325 FIXED Preferences tabs are displayed incorrectly if hovering it while searching any keyword 2019-01-09 17:21:13 +02:00
lltabcontainer.h
lltextbase.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
lltextbase.h
lltextbox.cpp Merged in lindenlab/viewer-release 2019-09-10 20:30:25 +03:00
lltextbox.h
lltexteditor.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
lltexteditor.h
lltextparser.cpp
lltextparser.h
lltextutil.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
lltextutil.h
lltextvalidate.cpp
lltextvalidate.h
lltimectrl.cpp
lltimectrl.h
lltoggleablemenu.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
lltoggleablemenu.h
lltoolbar.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
lltoolbar.h
lltooltip.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
lltooltip.h
lltrans.cpp
lltrans.h
lltransutil.cpp SL-10423 Dump path data when missing critical file 2019-06-03 21:37:43 +03:00
lltransutil.h
llui.cpp Merged in lindenlab/viewer-release 2019-08-14 15:02:56 +03:00
llui.h DRTVWR-493: Streamline LLParamSingleton, LLLockedSingleton. 2019-08-12 09:44:56 -04:00
lluicolor.cpp
lluicolor.h
lluicolortable.cpp
lluicolortable.h
lluiconstants.h
lluictrl.cpp
lluictrl.h
lluictrlfactory.cpp
lluictrlfactory.h
lluifwd.h
lluistring.cpp
lluistring.h
llundo.cpp
llundo.h
llurlaction.cpp
llurlaction.h
llurlentry.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llurlentry.h
llurlmatch.cpp
llurlmatch.h
llurlregistry.cpp
llurlregistry.h
llview.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llview.h DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llviewborder.cpp
llviewborder.h
llviewereventrecorder.cpp DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llviewereventrecorder.h
llviewinject.cpp
llviewinject.h DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
llviewmodel.cpp
llviewmodel.h
llviewquery.cpp
llviewquery.h
llwindowshade.cpp
llwindowshade.h
llxuiparser.cpp
llxuiparser.h