diff --git a/indra/llcommon/aithreadsafe.h b/indra/llcommon/aithreadsafe.h index e22f587e2..225be3681 100644 --- a/indra/llcommon/aithreadsafe.h +++ b/indra/llcommon/aithreadsafe.h @@ -256,6 +256,8 @@ class AIThreadSafeDC : public AIThreadSafe public: // Construct a wrapper around a default constructed object. AIThreadSafeDC(void) { new (AIThreadSafe::ptr()) T; } + // Allow an arbitrary parameter to be passed for construction. + template AIThreadSafeDC(T2 const& val) { new (AIThreadSafe::ptr()) T(val); } }; /** @@ -472,10 +474,12 @@ class AIThreadSafeSimpleDC : public AIThreadSafeSimple public: // Construct a wrapper around a default constructed object. AIThreadSafeSimpleDC(void) { new (AIThreadSafeSimple::ptr()) T; } + // Allow an arbitrary parameter to be passed for construction. + template AIThreadSafeSimpleDC(T2 const& val) { new (AIThreadSafeSimple::ptr()) T(val); } protected: // For use by AIThreadSafeSimpleDCRootPool - AIThreadSafeSimpleDC(LLAPRPool& parent) : AIThreadSafeSimple(parent) { new (AIThreadSafeSimple::ptr()) T; } + AIThreadSafeSimpleDC(LLAPRRootPool& parent) : AIThreadSafeSimple(parent) { new (AIThreadSafeSimple::ptr()) T; } }; // Helper class for AIThreadSafeSimpleDCRootPool to assure initialization of @@ -664,6 +668,17 @@ class AIThreadSafeSingleThreadDC : public AIThreadSafeSingleThread public: // Construct a wrapper around a default constructed object. AIThreadSafeSingleThreadDC(void) { new (AIThreadSafeSingleThread::ptr()) T; } + // Allow an arbitrary parameter to be passed for construction. + template AIThreadSafeSingleThreadDC(T2 const& val) { new (AIThreadSafeSingleThread::ptr()) T(val); } + + // Allow assigning with T. + AIThreadSafeSingleThreadDC& operator=(T const& val) { AIThreadSafeSingleThread::accessed(); *AIThreadSafeSingleThread::ptr() = val; return *this; } + // Allow writing to an ostream. + friend std::ostream& operator<<(std::ostream& os, AIThreadSafeSingleThreadDC const& wrapped_val) { wrapped_val.accessed(); return os << *wrapped_val.ptr(); } + + // Automatic conversion to T. + operator T&(void) { AIThreadSafeSingleThread::accessed(); return *AIThreadSafeSingleThread::ptr(); } + operator T const&(void) const { AIThreadSafeSingleThread::accessed(); return *AIThreadSafeSingleThread::ptr(); } }; /**