xtd 0.2.0
Loading...
Searching...
No Matches
lock_guard.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../object.hpp"
6#include "../block_scope.hpp"
7#include "monitor.hpp"
8
10namespace xtd {
12 namespace threading {
32 class core_export_ lock_guard final : public object {
33 public:
35
40 template<typename object_t>
41 explicit lock_guard(const object_t& obj) : obj_(monitor::get_ptr(obj)) {monitor::enter_ptr(obj_);}
43
47
49
58 void pulse();
59
66 void pulse_all();
67
82 bool wait(int32 milliseconds_timeout);
83
97 bool wait(const time_span& timeout);
98
111 bool wait();
113
114 private:
115 lock_guard() = delete;
116 monitor::object_ptr obj_;
117 };
118 }
119}
120
181#define lock_guard_(object)\
182 block_scope_(xtd::threading::lock_guard __xtd_lock_guard__(object))
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:42
Provides a mechanism that synchronizes access to objects with xtd::threading::monitor.
Definition lock_guard.hpp:32
void pulse_all()
Notifies all waiting threads of a change in the object's state.
bool wait(const time_span &timeout)
Releases the lock on an object and blocks the current thread until it reacquires the lock....
bool wait()
Releases the lock on an object and blocks the current thread until it reacquires the lock.
bool wait(int32 milliseconds_timeout)
Releases the lock on an object and blocks the current thread until it reacquires the lock....
void pulse()
Notifies a thread in the waiting queue of a change in the locked object's state.
lock_guard(const object_t &obj)
Create a xtd::threading::lock_guard object and acquires an exclusive lock on the specified obj.
Definition lock_guard.hpp:41
Provides a mechanism that synchronizes access to objects.
Definition monitor.hpp:130
Contains a constant used to specify an infinite amount of time. This class cannot be inherited.
Definition timeout.hpp:33
#define core_export_
Define shared library export.
Definition core_export.hpp:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
Contains xtd::threading::monitor class.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Represents a time interval.
Definition time_span.hpp:29