.. index:: pair: class; EE::System::ThreadLocalPtr .. _doxid-class_e_e_1_1_system_1_1_thread_local_ptr: template class EE::System::ThreadLocalPtr ========================================= .. toctree:: :hidden: Overview ~~~~~~~~ Pointer to a thread-local variable. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include template class ThreadLocalPtr: private :ref:`EE::System::ThreadLocal` { public: // construction :ref:`ThreadLocalPtr`(T* value = NULL); // methods T& :ref:`operator*`() const; T* :ref:`operator->`() const; :ref:`operator T*`() const; ThreadLocalPtr& :ref:`operator=`(T* value); ThreadLocalPtr& :ref:`operator=`(const ThreadLocalPtr& right); }; Inherited Members ----------------- .. ref-code-block:: cpp :class: doxyrest-overview-inherited-code-block public: // methods void :ref:`setValue`(void* value); void* :ref:`getValue`() const; .. _details-class_e_e_1_1_system_1_1_thread_local_ptr: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Pointer to a thread-local variable. :ref:`ThreadLocalPtr ` is a type-safe wrapper for storing pointers to thread-local variables. A thread-local variable holds a different value for each different thread, unlike normal variable that are shared. Its usage is completely transparent, so that it is similar to manipulating the raw pointer directly (like any smart pointer). Usage example: .. ref-code-block:: cpp MyClass object1; MyClass object2; ThreadLocalPtr objectPtr; void thread1() { objectPtr = &object1; // doesn't impact thread2 ... } void thread2() { objectPtr = &object2; // doesn't impact thread1 ... } int main() { // Create and launch the two threads Thread t1(&thread1); Thread t2(&thread2); t1.launch(); t2.launch(); return 0; } Construction ------------ .. index:: pair: function; ThreadLocalPtr .. _doxid-class_e_e_1_1_system_1_1_thread_local_ptr_1ae32030d4d6f1332312f240869ecc7d7f: .. ref-code-block:: cpp :class: doxyrest-title-code-block ThreadLocalPtr(T* value = NULL) Default constructor. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - value - Optional value to initalize the variable Methods ------- .. index:: pair: function; operator* .. _doxid-class_e_e_1_1_system_1_1_thread_local_ptr_1a2c065929d4d95dcf62ead5695a78a4bc: .. ref-code-block:: cpp :class: doxyrest-title-code-block T& operator*() const Overload of unary operator \* Like raw pointers, applying the \* operator returns a reference to the pointed object. .. rubric:: Returns: Reference to the pointed object .. index:: pair: function; operator-> .. _doxid-class_e_e_1_1_system_1_1_thread_local_ptr_1a1dae15c92738c71024f51389e3da952e: .. ref-code-block:: cpp :class: doxyrest-title-code-block T* operator->() const Overload of operator -> Like raw pointers, applying the -> operator returns the pointed object. .. rubric:: Returns: Pointed object .. index:: pair: function; operator T* .. _doxid-class_e_e_1_1_system_1_1_thread_local_ptr_1a60781fb286dffc2b55bd74656a48fb00: .. ref-code-block:: cpp :class: doxyrest-title-code-block operator T*() const Cast operator to implicitely convert the pointer to its raw pointer type (T\*) .. rubric:: Returns: Pointer to the actual object .. index:: pair: function; operator= .. _doxid-class_e_e_1_1_system_1_1_thread_local_ptr_1a2596b9a66c825c45ec819e03f615f412: .. ref-code-block:: cpp :class: doxyrest-title-code-block ThreadLocalPtr& operator=(T* value) Assignment operator for a raw pointer parameter. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - value - Pointer to assign .. rubric:: Returns: Reference to self .. index:: pair: function; operator= .. _doxid-class_e_e_1_1_system_1_1_thread_local_ptr_1ad54242b7f1d896d2cf918cc6441c3e74: .. ref-code-block:: cpp :class: doxyrest-title-code-block ThreadLocalPtr& operator=(const ThreadLocalPtr& right) Assignment operator for a :ref:`ThreadLocalPtr ` parameter. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - right - :ref:`ThreadLocalPtr ` to assign .. rubric:: Returns: Reference to self