The xtd::call_once struct can be used to execute a routine exactly once. This can be used to initialise data in a thread-safe way.
- Namespace
- xtd
- Library
- xtd.core
- Examples
- The following example shows how to use xtd::call_once struct.
#include <xtd/xtd>
auto main() -> int {
auto thread_proc = [&] {
static auto cpt = 0;
[[maybe_unused]]
static auto __call_once__ =
call_once {} + [&] {
};
if (cpt == 3) mre.set();
};
mre.wait_one();
}
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
Represents a thread synchronization event that, when signaled, must be reset manually....
Definition manual_reset_event.hpp:35
static registered_wait_handle register_wait_for_single_object(wait_handle &wait_object, const wait_or_timer_callback &callback, const xtd::any_object &state, int32 milliseconds_timeout_interval, bool execute_only_once)
Registers a delegate to wait for a xtd::threading::wait_handle, specifying a 32-bit signed integer fo...
static void join_all()
Blocks the calling thread until all joinable threads terminate.
The xtd::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.hpp:11
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
The xtd::call_once struct can be used to execute a routine exactly once. This can be used to initiali...
Definition call_once.hpp:19
- Examples
- call_once2.cpp.
The documentation for this struct was generated from the following file: