8#include "../invalid_operation_exception.h"
10#include "../time_span.h"
37 template<
typename value_t>
39 struct data :
public object {
41 bool track_all_values =
false;
43 std::map<intptr, value_t> values;
46 struct lock_guard_mutex {
48 ~lock_guard_mutex() {mutex_.unlock();}
73 data_->value_factory = value_factory;
74 data_->track_all_values = track_all_values;
79 template<
typename func_t>
81 template<
typename func_t>
94 lock_guard_mutex
lock {data_->mutex};
102 lock_guard_mutex
lock {data_->mutex};
111 lock_guard_mutex
lock {data_->mutex};
121 lock_guard_mutex
lock {data_->mutex};
122 auto values = std::vector<value_t> {};
123 for (
const auto& entry : data_->values)
124 values.push_back(entry.second);
138 mutable std::shared_ptr<data> data_ = std::make_shared<data>();
Represents a delegate, which is a data structure that refers to a static method or to a class instanc...
Definition delegate.h:363
The exception that is thrown when a method call is invalid for the object's current state.
Definition invalid_operation_exception.h:18
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:32
Provides a mechanism that synchronizes access to objects with xtd::threading::monitor.
Definition lock_guard.h:30
A synchronization primitive that can also be used for interprocess synchronization.
Definition mutex.h:48
Provides thread-local storage of data.
Definition thread_local_object.h:38
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.h:64
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.h:72
void value(value_t value) noexcept
Sets the value of this instance for the current thread.
Definition thread_local_object.h:110
thread_local_object()=default
Initializes the xtd::threading::thread_local_object instance.
bool is_value_created() const noexcept
Gets whether xtd::threading::thread_local_object::value is initialized on the current thread.
Definition thread_local_object.h:93
ustring to_string() const noexcept override
Returns a sxd::ustring that represents the current object.
Definition thread_local_object.h:132
value_t value() const noexcept
Gets the value of this instance for the current thread.
Definition thread_local_object.h:101
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.h:119
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.h:67
intptr thread_id() const noexcept
Gets the native operating system thread id.
static thread & current_thread() noexcept
Gets the currently running thread.
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
#define csf_
Provides information about the current stack frame.
Definition current_stack_frame.h:30
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.h: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.h:10
Contains xtd::threading::thread class.