summaryrefslogtreecommitdiff
path: root/indra/llcommon/llinstancetracker.h
AgeCommit message (Collapse)Author
2024-04-29#824 Process source files in bulk: replace tabs with spaces, convert CRLF to ↵Andrey Lihatskiy
LF, and trim trailing whitespaces as needed
2023-05-17Merge remote-tracking branch 'origin/main' into DRTVWR-559Brad Linden
2022-12-09DRTVWR-559: Introduce LLInstanceTrackerSubclass mediator class.Nat Goodspeed
Deriving your tracked class T from LLInstanceTracker<T> gives you T::getInstance() et al. But what about a subclass S derived from T? S::getInstance() still delivers a pointer to T, requiring explicit downcast. And so on for other LLInstanceTracker methods. Instead, derive S from LLInstanceTrackerSubclass<S, T>. This implies that S is a grandchild class of T, but it also recasts the LLInstanceTracker methods to deliver results for S rather than for T.
2022-11-03DRTVWR-575: Fix llcommon assumptions that size_t fits in 4 bytes.Nat Goodspeed
It's a little distressing how often we have historically coded S32 or U32 to pass a length or index. There are more such assumptions in other viewer subdirectories, but this is a start.
2021-10-07SL-16024: Return shared_ptr from LLInstanceTracker::getInstance().Nat Goodspeed
It feels wrong to return a dumb LLInstanceTracker subclass* from getInstance() when we use std::shared_ptr and std::weak_ptr internally. But tweak consumers to use 'auto' or LLInstanceTracker::ptr_t in case we later revisit this decision. We did add a couple get() calls where it's important to obtain a dumb pointer.
2020-03-25DRTVWR-476: Adapt LLInstanceTracker::snapshot for VS limitations.Nat Goodspeed
2020-03-25DRTVWR-494: Move LL_ERRS out of llinstancetracker.h header file.Nat Goodspeed
Add a namespaced free function in .cpp file to report LL_ERRS as needed. Per code review, use a more indicative namespace name.
2020-03-25DRTVWR-494: Extract LockStatic as a standalone template class.Nat Goodspeed
The pattern of requiring a lock to permit *any* access to a static instance of something seems generally useful. Break out lockstatic.h; recast LLInstanceTracker to use it. Moving LockStatic to an external template class instead of a nested class in LLInstanceTrackerBase leaves LLInstanceTrackerBase pretty empty. Get rid of it. And *that* means we can move the definition of the StaticData used by each LLInstanceTracker specialization into the class itself, rather than having to define it beforehand in namespace LLInstanceTrackerStuff.
2020-03-25DRTVWR-494: Encapsulate redundant VS boilerplate around <mutex>.Nat Goodspeed
2020-03-25DRTVWR-494: Quiet VS warnings about its own <mutex> header.Nat Goodspeed
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-01-15SL-10291 Replace apr_atomic with standard C++11 functionalityandreykproductengine
2017-05-08DRTVWR-418: Work around VS2013's lack of __has_feature().Nat Goodspeed
2017-05-08DRTVWR-418: Fix -std=c++11 llinstancetracker_test crash.Nat Goodspeed
LLInstanceTracker<T> performs validation in ~LLInstanceTracker(). Normally validation failure logs an error and terminates the program, which is fine. In the test executable, though, we want validation failure to throw an exception instead so we can catch it and continue testing other failure conditions. But since destructors in C++11 are implicitly noexcept(true), that exception never made it out of ~LLInstanceTracker(): it crashed the test program instead. Declaring ~LLInstanceTracker() noexcept(false) solves that, allowing the test program to catch the exception and continue. However, if we unconditionally declare that, then every destructor anywhere in the inheritance hierarchy for any LLInstanceTracker subclass must also be noexcept(false)! That's way too pervasive, especially for functionality we only need (or want) in a specific test executable. Instead, make the CMake macros LL_ADD_PROJECT_UNIT_TESTS() and LL_ADD_INTEGRATION_TEST() -- with which we define all viewer build-time tests -- define two new command-line macros: LL_TEST=testname and LL_TEST_testname. That way, preprocessor logic in a header file can detect whether it's being compiled for production code or for a test executable. (While at it, encapsulate in a new GET_OPT_SOURCE_FILE_PROPERTY() CMake macro an ugly repetitive pattern. The builtin GET_SOURCE_FILE_PROPERTY() sets the target variable to "NOTFOUND" -- rather than an empty string -- if the specified property wasn't set. Every call to GET_SOURCE_FILE_PROPERTY() in LL_ADD_PROJECT_UNIT_TESTS() was followed by a test for NOTFOUND and an assignment to "". Wrap all that in a macro whose 'unset' value is "".) Now llinstancetracker.h can detect when we're building the LLInstanceTracker unit test executable, and *only then* declare ~LLInstanceTracker() as noexcept(false). We #define LLINSTANCETRACKER_DTOR_NOEXCEPT to expand either empty or noexcept(false), also detecting clang in C++11 mode. (It all works fine without noexcept(false) until we turn on C++11 mode.) We also use that macro for the StatBase class in lltrace.h. Turns out some of the infrastructure headers required for tests in general, including the LLInstanceTracker test, use LLInstanceTracker. Fortunately that appears to be the only other class we must annotate this way for the LLInstanceTracker tests.
2015-11-10remove execute permission from many files that should not have itOz Linden
2013-11-20SH-4626 FIX: [INTERESTING RC] Viewer randomly crashes when I click on links ↵Richard Linden
in IMs or group IMs
2013-11-19SH-4634 FIX Interesting: Viewer crashes when receiving teleport offerRichard Linden
renamed fast timers to have unique names, changes instance tracker to never allow duplicates
2013-10-24SH-4577 WIP Interesting: viewer crashed when clicking a offline Conversation ↵Richard Linden
containing a shared object potential fix by making instance tracker allow key collisions for LLToastNotifyPanel changed assertion macro to use original unpreprocessed source code renamed instance tracker behavior macros to use LL prefix added RestoreCameraPosOnLogin setting to optionally restore old camera positioning behavior
2013-10-17fix for assert at runtime (reading stats from recording while it was active)Richard Linden
fix for bad values returns from getPeriodMin and getPeriodMax on count stats when no counts recorded fix for gcc compile time error (typename ftw)
2013-10-17moved root timer to global variableRichard Linden
added flag to LLInstanceTracker to allow multiple values per key made StatType allow multiple values per key to eliminate block timer related crash
2013-10-08merge from viewer-releaseRichard Linden
2013-08-26Tweak MAINT-3046 fix for faster remove_() performancesimon
2013-08-23MAINT-3046 make LLNotifications clear out vecs of LLNotificationChannelPtr ↵Graham Madarasz (Graham Linden)
so singleton cleanup doesn't do things it really ought not do
2013-07-30Summer cleaning - removed a lot of llcommon dependencies to speed up build timesRichard Linden
consolidated most indra-specific constants in llcommon under indra_constants.h fixed issues with operations on mixed unit types (implicit and explicit) made LL_INFOS() style macros variadic in order to subsume other logging methods such as ll_infos added optional tag output to error recorders
2013-07-18SH-4297 WIP interesting: viewer-interesting starts loading cached scene lateRichard Linden
dependency cleanup - removed a lot of unecessary includes
2013-06-05merge with viewer-releaseRichard Linden
2013-05-09Merge downstream code and viewer-betasimon
2013-04-24diff -r 59c7bed66dfd indra/llcommon/lleventapi.hsimon
2013-04-21SH-3931 WIP Interesting: Add graphs to visualize scene load metricsRichard Linden
added ExtendablePeriodicRecording and ability to append periodic recordings to each other
2013-04-19SH-4080 WIP interesting: random crash on MacRichard Linden
removed unused dll support from llinstancetracker as it didn't appear to be thread safe
2013-04-17Some minor cleanups while hunting crashes. Reviewed by Kellysimon
2013-03-29Update Mac and Windows breakpad builds to latestGraham Madarasz
2013-03-19Merge in viewer-beta to get CHUI codeSimon Linden
2013-03-01Added missing enums for integ test usageGraham Madarasz (Graham)
2013-02-28Modify LLInstanceTracker to avoid using a map of strings to find a map of ↵Graham Madarasz (Graham)
foo to find some pointers
2012-12-23SH-3468 WIP add memory tracking base classRichard Linden
fixed crash on exit by making LLInstanceTracker iterators use atomic iterator nesting count for thread safety
2012-11-01SH-3405 FIX convert existing stats to lltrace systemRichard Linden
final removal of remaining LLStat code
2012-07-27Pull and merge from ssh://hg@bitbucket.org/lindenlab/viewer-release.Todd Stinson
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.
2012-03-29CHUI-51 WIP notifications routig code cleanupRichard Linden
phase 2, removal of extraneous signaling in favor of llnotificationchannels made notificationchannels work better with overrides and lifetime managed by creator
2011-10-17fixed one crash on exitRichard Nelson
2011-09-07STORM-1541: Change llassert() to llassert_always(): unit tests expect.Nat Goodspeed
Now that we have unit tests that require assertion failure if you try to delete an LLInstanceTracker subclass instance with an iterator loose, having llassert() "sometimes" compile away (whimsically, depending on platform as well as build type!) makes those tests fail. Use llassert_always() instead.
2011-09-06STORM-1541: Hoist LLInstanceTracker::getMap_() to base getStatic().Nat Goodspeed
Generalize the notion of getting some chunk of "static" storage: introduce LLInstanceTrackerBase::getStatic() template method. Define StaticData struct containing the InstanceMap (or InstanceSet, for that specialization) along with the S32 that caused the VS2010 linker so much grief. Completely eliminate that S32 as an actual class-static member, qualifying all references with the struct returned by getStatic(). In LLInstanceTrackerBase::getInstances(), use one std::map lookup instead of three.
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-27Swap typename and const.Aaron Stone
2011-07-27another potential gcc fixRichard Nelson
2011-07-27broken operator= semantics for instance tracker iteratorsRichard Nelson
2011-07-27 another fix for buildRichard Nelson
2011-07-26fixed buildRichard Nelson
2011-07-26removed last vestiges of llinstancetracerscopedguardRichard Nelson