summaryrefslogtreecommitdiff
path: root/indra/llcommon/tests/llinstancetracker_test.cpp
AgeCommit message (Collapse)Author
2020-03-25DRTVWR-476: Re-enable LLInstanceTracker tests disabled months ago.Nat Goodspeed
2020-03-25[DRTVWR-476] - temporary skip failing llinstancetracker tests to get TC ↵Anchor
build working
2020-03-25DRTVWR-494: Defend LLInstanceTracker against multi-thread usage.Nat Goodspeed
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-08-12DRTVWR-493: Make catch_llerrs() a member of WrapLLErrs.Nat Goodspeed
2019-08-10DRTVWR-493: Introduce test catch_what(), catch_llerrs() functions.Nat Goodspeed
Use them in place of awkward try/catch test boilerplate.
2015-11-10remove execute permission from many files that should not have itOz Linden
2013-10-21BUILDFIX: double delete in instancetracker unit testRichard Linden
2013-10-18fixed llinstancetracker unit testRichard Linden
2013-04-19merge changes for DRTVWR-294Oz Linden
2013-03-29Update Mac and Windows breakpad builds to latestGraham Madarasz
2012-10-11Updating linux build to gcc4.6Don Kjer
2012-02-27Automated merge with file:///Users/nat/linden/viewer-leap-daggyNat Goodspeed
2012-02-27Add LLInstanceTracker test for exception in subclass constructor.Nat Goodspeed
We want to verify the sequence: LLInstanceTracker constructor adds instance to underlying container Subclass constructor throws exception LLInstanceTracker destructor removes instance from underlying container.
2012-02-27Make LLInstanceTracker<T, T*>::getInstance(T*) validate passed T*.Nat Goodspeed
For the T* specialization (no string, or whatever, key), the original getInstance() method simply returned the passed-in T* value. It was defined, as the comments noted, for completeness of the analogy with the keyed LLInstanceTracker specialization. It turns out, though, that getInstance(T*) can still be useful to ask whether the T* you have in hand still references a valid T instance. Support that usage.
2011-09-07STORM-1541: Add LLInstanceTracker tests for active-iterator asserts.Nat Goodspeed
The recent class-static LLInstanceTracker::instance_iter and key_iter reference count is intended to guard against deleting an instance of an LLInstanceTracker subclass during iteration. Add tests for that functionality.
2011-08-24Re-add 3 llinstancetracker tests disabled by changeset 1ead63777bf6.Nat Goodspeed
Fix LLInstanceTracker::key_iter constructor param; accepting InstanceMap::iterator by non-const reference relied on Microsoft extension that accepts non-const reference to an rvalue. Given typical iterator implementation, simply accept by value instead, which makes gcc happy too.
2011-07-27fix for gccRichard Nelson
2011-07-26fixed buildRichard Nelson
2011-07-26removed last vestiges of llinstancetracerscopedguardRichard Nelson
2010-08-13Change license from GPL to LGPL (version 2.1)Oz Linden
2010-02-06EXT-5055 LLInstanceTracker promotes some dangerous patterns - detect themTofu Linden
2009-11-10Enhance LLInstanceTracker variants to be more uniform.Nat Goodspeed
For both the (so far unused) generic KEY form and the KEY = T* form, provide key_iter, beginKeys(), endKeys(). Change instance_iter so that when dereferenced, it gives you a T& rather than a T*, to be more harmonious with a typical STL container. (You parameterize LLInstanceTracker with T, not with T*.) Fix existing usage in llfasttimer.cpp and lltimer.cpp to agree. For the KEY = T* specialization, add T* getInstance(T*) so client isn't forced to know which variant was used. Add unit tests for uniformity of public operations on both variants.