#include <xtd/threading/auto_reset_event>
#include <xtd/threading/interlocked>
#include <xtd/threading/thread>
#include <xtd/threading/thread_pool>
#include <xtd/console>
#include <xtd/lock>
#include <xtd/startup>
namespace monitor_lock_example {
class sync_resource :
public object {
public:
void access() {
}
}
};
class un_sync_resource :
public object {
public:
void access() {
}
};
class app {
private:
inline static int num_ops = 0;
inline static sync_resource sync_res;
inline static un_sync_resource un_sync_res;
public:
static void main() {
num_ops = 5;
for (int ctr = 0; ctr <= 4; ++ctr)
ops_are_done.wait_one();
num_ops = 5;
for (int ctr = 0; ctr <= 4; ctr++)
ops_are_done.wait_one();
}
static void sync_update_resource(std::any state) {
sync_res.access();
ops_are_done.set();
}
static void un_sync_update_resource(std::any state) {
un_sync_res.access();
ops_are_done.set();
}
};
}
startup_(monitor_lock_example::app::main);
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
Represents a thread synchronization event that, when signaled, resets automatically after releasing a...
Definition auto_reset_event.hpp:36
static int32 decrement(int32 &location) noexcept
Decrements a specified variable and stores the result, as an atomic operation.
static bool queue_user_work_item(const wait_callback &callback)
Queues a method for execution. The method executes when a thread pool thread becomes available.
static thread & current_thread() noexcept
Gets the currently running thread.
static void sleep(int32 milliseconds_timeout)
Suspends the current thread for a specified time.
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:167
#define lock_(object)
The lock_ keyword marks a statement block as a critical section by obtaining the mutual-exclusion loc...
Definition lock.hpp:85
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