39 template<
class 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<
class func_t>
83 template<
class 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};
125 for (
const auto& entry : data_->values)
135 return string::format(
"{}",
value());
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:61
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
Throws an exption with specified exception case.
object()=default
Create a new instance of the ultimate base class object.
A synchronization primitive that can also be used for interprocess synchronization.
Definition mutex.hpp:50
void lock()
Locks the mutex. If another thread has already locked the mutex, a call to lock will block execution ...
void unlock()
Unlocks the mutex.
Provides thread-local storage of data.
Definition thread_local_object.hpp:40
xtd::array< 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(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
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.
Contains xtd::func delegate.
xtd::delegate< result_t(arguments_t... arguments)> func
Represents a delegate that has variables parameters and returns a value of the type specified by the ...
Definition func.hpp:27
@ invalid_operation
The operation is not valid.
Definition exception_case.hpp:63
xtd::threading::lock_guard lock
Provides a mechanism that synchronizes access to objects with xtd::threading::monitor.
Definition lock.hpp:22
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
sptr< type_t > new_sptr(args_t &&... args)
xtd::new_sptr operator creates a xtd::sptr object.
Definition new_sptr.hpp:24
@ other
The operating system is other.
Definition platform_id.hpp:58
Contains xtd::invalid_operation_exception exception.
Contains xtd::threading::mutex exception.
The xtd::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::object class.
Contains xtd::threading::thread class.
Contains xtd::time_span class.