xtd 0.2.0
Loading...
Searching...
No Matches
lock.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 final : public object {
33 public:
35
40 template<class object_t>
41 explicit lock(const object_t& obj) : obj_(monitor::get_ptr(obj)) {monitor::enter_ptr(obj_);}
43
45 ~lock();
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() = delete;
116 monitor::object_ptr obj_;
117 };
118 }
119}
120
121#include "../lock.hpp"
Contains block_scope_ keyword.
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
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.
bool wait(const time_span &timeout)
Releases the lock on an object and blocks the current thread until it reacquires the lock....
lock(const object_t &obj)
Create a xtd::threading::lock object and acquires an exclusive lock on the specified obj.
Definition lock.hpp:41
void pulse_all()
Notifies all waiting threads of a change in the object's state.
bool wait()
Releases the lock on an object and blocks the current thread until it reacquires the lock.
Provides a mechanism that synchronizes access to objects.
Definition monitor.hpp:129
Contains a constant used to specify an infinite amount of time. This class cannot be inherited.
Definition timeout.hpp:33
Represents a time interval.
Definition time_span.hpp:29
#define core_export_
Define shared library export.
Definition core_export.hpp:13
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
Contains lock_ keyword.
Contains xtd::threading::monitor class.
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.