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};
103 [[nodiscard]]
auto value() const noexcept -> value_t {
104 lock_guard_mutex
lock {data_->mutex};
112 lock_guard_mutex
lock {data_->mutex};
122 lock_guard_mutex
lock {data_->mutex};
124 for (
const auto& entry : data_->values)
133 [[nodiscard]]
auto to_string() const noexcept ->
string override {
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
Throws an exption with specified exception case.
object()=default
Create a new instance of the ultimate base class object.
Provides a mechanism that synchronizes access to objects with xtd::threading::monitor.
Definition lock.hpp:32
A synchronization primitive that can also be used for interprocess synchronization.
Definition mutex.hpp:50
auto lock() -> void
Locks the mutex. If another thread has already locked the mutex, a call to lock will block execution ...
auto unlock() -> void
Unlocks the mutex.
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
auto value(value_t value) noexcept -> void
Sets the value of this instance for the current thread.
Definition thread_local_object.hpp:111
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
auto value() const noexcept -> value_t
Gets the value of this instance for the current thread.
Definition thread_local_object.hpp:103
thread_local_object()=default
Initializes the xtd::threading::thread_local_object instance.
auto to_string() const noexcept -> string override
Returns a xtd::string that represents the current object.
Definition thread_local_object.hpp:133
auto values() const -> xtd::array< value_t >
Gets a list containing the values stored by all threads that have accessed this instance.
Definition thread_local_object.hpp:120
auto is_value_created() const noexcept -> bool
Gets whether xtd::threading::thread_local_object::value is initialized on the current thread.
Definition thread_local_object.hpp:95
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
static auto current_thread() noexcept -> thread &
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:65
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:60
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.