phoenix-firestorm/indra/llrender
Nat Goodspeed 9d5b897600 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.
2020-03-25 15:28:17 -04:00
..
CMakeLists.txt MAINT-7213 Shared media (media as a texture) unusable with transparent mesh 2017-10-26 18:33:08 +03:00
llcubemap.cpp remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
llcubemap.h remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
llfontbitmapcache.cpp remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
llfontbitmapcache.h remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
llfontfreetype.cpp SL-11139 FIXED LLFontGL::getStringFromStyle() never return "NORMAL" 2019-05-13 18:17:16 +03:00
llfontfreetype.h SL-10610 FIXED Floaters fails to display certain symbols. Added ability to load font collections. 2019-03-19 11:16:24 +02:00
llfontgl.cpp SL-11139 FIXED LLFontGL::getStringFromStyle() never return "NORMAL" 2019-05-13 18:17:16 +03:00
llfontgl.h SL-10610 FIXED Floaters fails to display certain symbols. Added ability to load font collections. 2019-03-19 11:16:24 +02:00
llfontregistry.cpp SL-10610 FIXED Floaters fails to display certain symbols. Added ability to load font collections. 2019-03-19 11:16:24 +02:00
llfontregistry.h SL-10610 FIXED Floaters fails to display certain symbols. Added ability to load font collections. 2019-03-19 11:16:24 +02:00
llgl.cpp DRTVWR-494: Defend LLInstanceTracker against multi-thread usage. 2020-03-25 15:28:17 -04:00
llgl.h MAINT-7213 Shared media (media as a texture) unusable with transparent mesh 2017-10-26 18:33:08 +03:00
llglcommonfunc.cpp MAINT-7213 Shared media (media as a texture) unusable with transparent mesh 2017-10-26 18:33:08 +03:00
llglcommonfunc.h MAINT-7213 Shared media (media as a texture) unusable with transparent mesh 2017-10-26 18:33:08 +03:00
llgldbg.cpp remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
llgldbg.h remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
llglheaders.h MAINT-6913 - (Via Sovereign Engineer and Shyotl Kuhr) Pack the skinned matrix and translation into a single mat3x4 for optimal data transfer to reduce uniform slot usage. 2016-11-11 09:37:45 -05:00
llglslshader.cpp MAINT-3699 new shaders supporting alpha blend/mask rigged content. 2018-08-16 00:31:39 +01:00
llglslshader.h Keep attributes name (useful for debug) 2018-01-30 17:07:00 +02:00
llglstates.h remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
llgltexture.cpp MAINT-5297 - icons were not removed from memory 2016-02-24 16:22:38 +02:00
llgltexture.h MAINT-6363 Normal and specular maps should not be downloaded if ALM is off 2018-03-06 12:59:32 +00:00
llgltypes.h remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
llimagegl.cpp MAINT-8923 Better allocation failure handling, createGLTexture crashes 2018-07-26 20:06:26 +03:00
llimagegl.h MAINT-8043 Fix for bad_alloc crash in LLImageGL::setImage() 2017-12-18 20:29:50 +02:00
llpostprocess.cpp remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
llpostprocess.h remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
llrender.cpp Add debug setting and code to allow nVidia nSight graphics debugging to capture SL frames. 2018-02-15 21:55:24 +00:00
llrender.h MAINT-8317 Fixed Local Textures for Advanced Lighting Projectors do not keep the selected texture. 2018-02-27 15:49:15 +02:00
llrender2dutils.cpp Fix instance existance check 2019-11-12 16:07:36 +02:00
llrender2dutils.h SL-11718 Crash in LLRender2D 2019-08-13 17:22:58 +03:00
llrendernavprim.cpp remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
llrendernavprim.h remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
llrendersphere.cpp remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
llrendersphere.h remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
llrendertarget.cpp remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
llrendertarget.h remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
llshadermgr.cpp MAINT-3699 new shaders supporting alpha blend/mask rigged content. 2018-08-16 00:31:39 +01:00
llshadermgr.h Backed out changeset: 5fe5ad059c05 2016-07-18 20:09:18 +03:00
lltexture.cpp remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
lltexture.h remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
lluiimage.cpp DRTVWR-493 LLRender2D to LLParamSingleton 2019-07-25 18:20:17 +03:00
lluiimage.h fixed focus issue on inventory 2013-11-05 19:26:23 -08:00
llvertexbuffer.cpp MAINT-8686 Mode detailed VBO crash logging 2018-06-04 19:37:30 +03:00
llvertexbuffer.h Add const 2018-01-30 17:07:27 +02:00