Provides thread-local storage of data.
Public Constructors | |
thread_local_object ()=default | |
Initializes the xtd::threading::thread_local_object instance. | |
thread_local_object (bool track_all_values) | |
Initializes the xtd::threading::thread_local_object instance and specifies whether all values are accessible from any thread. | |
thread_local_object (const func< value_t > &value_factory) | |
Initializes the xtd::threading::thread_local_object instance with the specified value_factory function. | |
thread_local_object (const func< value_t > &value_factory, bool track_all_values) | |
Initializes the xtd::threading::thread_local_object instance with the specified value_factory function and a flag that indicates whether all values are accessible from any thread. | |
Public Properties | |
bool | is_value_created () const noexcept |
Gets whether xtd::threading::thread_local_object::value is initialized on the current thread. | |
value_t | value () const noexcept |
Gets the value of this instance for the current thread. | |
void | value (value_t value) noexcept |
Sets the value of this instance for the current thread. | |
std::vector< value_t > | values () const |
Gets a list containing the values stored by all threads that have accessed this instance. | |
Public Methods | |
string | to_string () const noexcept override |
Returns a xtd::string that represents the current object. | |
Additional Inherited Members | |
Public Member Functions inherited from xtd::object | |
object ()=default | |
Create a new instance of the ultimate base class object. | |
virtual bool | equals (const object &obj) const noexcept |
Determines whether the specified object is equal to the current object. | |
virtual size_t | get_hash_code () const noexcept |
Serves as a hash function for a particular type. | |
virtual type_object | get_type () const noexcept |
Gets the type of the current instance. | |
template<typename object_t > | |
xtd::uptr< object_t > | memberwise_clone () const |
Creates a shallow copy of the current object. | |
Static Public Member Functions inherited from xtd::object | |
template<typename object_a_t , typename object_b_t > | |
static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are considered equal. | |
template<typename object_a_t , typename object_b_t > | |
static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are the same instance. | |
|
default |
Initializes the xtd::threading::thread_local_object instance.
|
inlineexplicit |
Initializes the xtd::threading::thread_local_object instance and specifies whether all values are accessible from any thread.
track_all_values | true to track all values set on the instance and expose them through the xtd::threading::thread_local_object::values property; false otherwise. When set to true, a value stored from a given thread will be available through xtd::threading::thread_local_object::values even after that thread has exited. |
|
inlineexplicit |
Initializes the xtd::threading::thread_local_object instance with the specified value_factory function.
value_factory | The xtd::func invoked to produce a lazily-initialized value when an attempt is made to retrieve xtd::threading::thread_local_object::value without it having been previously initialized. |
|
inline |
Initializes the xtd::threading::thread_local_object instance with the specified value_factory function and a flag that indicates whether all values are accessible from any thread.
value_factory | The xtd::func invoked to produce a lazily-initialized value when an attempt is made to retrieve Value without it having been previously initialized. |
track_all_values | true to track all values set on the instance and expose them through the xtd::threading::thread_local_object::values property; false otherwise. When set to true, a value stored from a given thread will be available through xtd::threading::thread_local_object::values even after that thread has exited. |
|
inlinenoexcept |
Gets whether xtd::threading::thread_local_object::value is initialized on the current thread.
|
inlinenoexcept |
Gets the value of this instance for the current thread.
|
inlinenoexcept |
Sets the value of this instance for the current thread.
value | An instance of the object that this xtd::threading::thread_local_object::value is responsible for initializing. |
|
inline |
Gets a list containing the values stored by all threads that have accessed this instance.
xtd::invalid_operation_exception | Values stored by all threads are not available because this instance was initialized with the track_all_values argument set to false in the call to a class constructor. |
|
inlineoverridevirtualnoexcept |
Returns a xtd::string that represents the current object.
Reimplemented from xtd::object.