38 template<
typename value_t>
40 struct data :
public object {
42 bool track_all_values =
false;
44 std::map<intptr, value_t>
values;
47 struct lock_guard_mutex {
49 ~lock_guard_mutex() {mutex_.
unlock();}
74 data_->value_factory = value_factory;
75 data_->track_all_values = track_all_values;
80 template<
typename func_t>
82 template<
typename func_t>
95 lock_guard_mutex
lock {data_->mutex};
102 [[nodiscard]]
auto value() const noexcept -> value_t {
103 lock_guard_mutex
lock {data_->mutex};
111 lock_guard_mutex
lock {data_->mutex};
121 lock_guard_mutex
lock {data_->mutex};
123 for (
const auto& entry : data_->values)
132 [[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:39
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:65
auto value(value_t value) noexcept -> void
Sets the value of this instance for the current thread.
Definition thread_local_object.hpp:110
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:73
auto value() const noexcept -> value_t
Gets the value of this instance for the current thread.
Definition thread_local_object.hpp:102
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:132
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:119
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:94
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:68
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
auto new_sptr(args_t &&... args) -> xtd::sptr< type_t >
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::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.