userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
mutex.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <atomic>
7
#include <chrono>
8
#include <mutex>
// for std locks
9
10
#include <
userver/engine/deadline.hpp
>
11
#include <userver/engine/impl/wait_list_fwd.hpp>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
engine
{
16
28
class
Mutex final {
29
public
:
30
Mutex();
31
~Mutex();
32
33
Mutex(
const
Mutex&) =
delete
;
34
Mutex(Mutex&&) =
delete
;
35
Mutex& operator=(
const
Mutex&) =
delete
;
36
Mutex& operator=(Mutex&&) =
delete
;
37
44
void
lock
();
45
50
void
unlock
();
51
56
[[nodiscard]]
bool
try_lock
() noexcept;
57
66
template <typename Rep, typename Period>
67
[[nodiscard]]
bool
try_lock_for
(const
std
::chrono::duration<Rep, Period>&);
68
77
template <typename Clock, typename Duration>
78
[[nodiscard]]
bool
try_lock_until
(const
std
::chrono::time_point<Clock, Duration>&);
79
81
[[nodiscard]]
bool
try_lock_until
(
Deadline
deadline);
82
83
private:
84
class Impl;
85
86
utils
::FastPimpl<Impl, 104, alignof(
void
*)> impl_;
87
};
88
89
template <typename Rep, typename Period>
90
bool
Mutex::
try_lock_for
(const
std
::chrono::duration<Rep, Period>& duration) {
91
return
try_lock_until
(
Deadline::FromDuration
(duration));
92
}
93
94
template
<
typename
Clock,
typename
Duration>
95
bool
Mutex::try_lock_until
(
const
std::chrono::time_point<Clock, Duration>& until) {
96
return
try_lock_until
(
Deadline::FromTimePoint
(until));
97
}
98
99
}
// namespace engine
100
101
USERVER_NAMESPACE_END
userver
engine
mutex.hpp
Generated on
for userver by
Doxygen
1.17.0