8#include "../invalid_operation_exception.hpp"
9#include "../object.hpp"
10#include "../time_span.hpp"
39 template<
typename value_t>
41 struct data :
public object {
43 bool track_all_values =
false;
45 std::map<intptr, value_t> values;
48 struct lock_guard_mutex {
50 ~lock_guard_mutex() {mutex_.unlock();}
75 data_->value_factory = value_factory;
76 data_->track_all_values = track_all_values;
81 template<
typename func_t>
83 template<
typename func_t>
96 lock_guard_mutex
lock {data_->mutex};
104 lock_guard_mutex
lock {data_->mutex};
113 lock_guard_mutex
lock {data_->mutex};
123 lock_guard_mutex
lock {data_->mutex};
124 auto values = std::vector<value_t> {};
125 for (
const auto& entry : data_->values)
126 values.push_back(entry.second);
Represents a delegate, which is a data structure that refers to a static method or to a class instanc...
Definition delegate.hpp:370
The exception that is thrown when the format of an argument does not meet the parameter specification...
Definition invalid_operation_exception.hpp:19
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:42
Provides a mechanism that synchronizes access to objects with xtd::threading::monitor.
Definition lock_guard.hpp:32
A synchronization primitive that can also be used for interprocess synchronization.
Definition mutex.hpp:50
Provides thread-local storage of data.
Definition thread_local_object.hpp:40
thread_local_object(bool track_all_values)
Initializes the xtd::threading::thread_local_object instance and specifies whether all values are acc...
Definition thread_local_object.hpp:66
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 functio...
Definition thread_local_object.hpp:74
void value(value_t value) noexcept
Sets the value of this instance for the current thread.
Definition thread_local_object.hpp:112
thread_local_object()=default
Initializes the xtd::threading::thread_local_object instance.
string to_string() const noexcept override
Returns a xtd::string that represents the current object.
Definition thread_local_object.hpp:134
bool is_value_created() const noexcept
Gets whether xtd::threading::thread_local_object::value is initialized on the current thread.
Definition thread_local_object.hpp:95
value_t value() const noexcept
Gets the value of this instance for the current thread.
Definition thread_local_object.hpp:103
std::vector< value_t > values() const
Gets a list containing the values stored by all threads that have accessed this instance.
Definition thread_local_object.hpp:121
thread_local_object(const func< value_t > &value_factory)
Initializes the xtd::threading::thread_local_object instance with the specified value_factory functio...
Definition thread_local_object.hpp:69
intptr thread_id() const noexcept
Gets the native operating system thread id.
static thread & current_thread() noexcept
Gets the currently running thread.
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
delegate< result_t(arguments_t...)> func
Represents a delegate that has variables parameters and returns a value of the type specified by the ...
Definition func.hpp:16
@ other
The operating system is other.
Contains xtd::threading::mutex exception.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Contains xtd::threading::thread class.