userver
C++ Async Framework
Toggle main menu visibility
Documentation
API Groups
Namespaces
Reference
Class List
Class Index
File List
Macros
All
e
i
l
r
t
u
Functions
Macros
e
i
l
r
t
u
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Concepts
Loading...
Searching...
No Matches
sleep.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/engine/sleep.hpp
4
/// @brief Time-based coroutine suspension helpers
5
6
#
include
<
chrono
>
7
8
#
include
<
userver
/
engine
/
deadline
.
hpp
>
9
10
USERVER_NAMESPACE_BEGIN
11
12
namespace
engine {
13
14
/// @brief Suspends execution for a brief period of time, possibly allowing
15
/// other tasks to execute
16
void
Yield
();
17
18
/// @cond
19
/// Recursion stoppers/specializations
20
void
InterruptibleSleepUntil(Deadline);
21
void
SleepUntil(Deadline);
22
/// @endcond
23
24
/// Suspends execution for at least the specified amount of time or until the
25
/// current task is cancelled. If already cancelled, the call is equivalent to
26
/// Yield.
27
template
<
typename
Rep,
typename
Period>
28
void
InterruptibleSleepFor
(
const
std::chrono::duration<Rep, Period>& duration) {
29
engine::InterruptibleSleepUntil(Deadline::FromDuration(duration));
30
}
28
void
InterruptibleSleepFor
(
const
std::chrono::duration<Rep, Period>& duration) {
…
}
31
32
/// Suspends execution until the specified time point is reached or until the
33
/// current task is cancelled. If already cancelled, the call is equivalent to
34
/// Yield.
35
template
<
typename
Clock,
typename
Duration>
36
void
InterruptibleSleepUntil
(
const
std::chrono::time_point<Clock, Duration>& time_point) {
37
engine::InterruptibleSleepUntil(Deadline::FromTimePoint(time_point));
38
}
36
void
InterruptibleSleepUntil
(
const
std::chrono::time_point<Clock, Duration>& time_point) {
…
}
39
40
/// Suspends execution for at least a specified amount of time, ignores
41
/// cancellation. Use engine::InterruptibleSleepFor to interrupt sleep by
42
/// cancellation request.
43
template
<
typename
Rep,
typename
Period>
44
void
SleepFor
(
const
std::chrono::duration<Rep, Period>& duration) {
45
engine::SleepUntil(Deadline::FromDuration(duration));
46
}
44
void
SleepFor
(
const
std::chrono::duration<Rep, Period>& duration) {
…
}
47
48
/// Suspends execution until the specified time point is reached, ignores
49
/// cancellation. Use engine::InterruptibleSleepUntil to interrupt sleep by
50
/// cancellation request.
51
template
<
typename
Clock,
typename
Duration>
52
void
SleepUntil
(
const
std::chrono::time_point<Clock, Duration>& time_point) {
53
engine::SleepUntil(Deadline::FromTimePoint(time_point));
54
}
52
void
SleepUntil
(
const
std::chrono::time_point<Clock, Duration>& time_point) {
…
}
55
56
}
// namespace engine
57
58
USERVER_NAMESPACE_END
userver
engine
sleep.hpp
Generated on Wed Apr 30 2025 15:53:09 for userver by
Doxygen
1.13.2