userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
dist_locked_task.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <chrono>
7
#include <functional>
8
#include <memory>
9
#include <optional>
10
#include <string>
11
12
#include <
userver/dist_lock/dist_lock_settings.hpp
>
13
#include <
userver/dist_lock/dist_lock_strategy.hpp
>
14
#include <
userver/engine/task/task_base.hpp
>
15
#include <
userver/engine/task/task_processor_fwd.hpp
>
16
#include <
userver/logging/level.hpp
>
17
18
USERVER_NAMESPACE_BEGIN
19
20
namespace
dist_lock
{
21
namespace
impl {
22
23
class
Locker;
24
25
}
// namespace impl
26
44
class
DistLockedTask
final :
public
engine::TaskBase
{
45
public
:
46
using
WorkerFunc = std::function<void()>;
47
50
DistLockedTask
() =
default
;
51
52
DistLockedTask
(
DistLockedTask
&&) =
delete
;
53
DistLockedTask
& operator=(
DistLockedTask
&&) =
delete
;
54
55
DistLockedTask
(
const
DistLockedTask
&) =
delete
;
56
DistLockedTask
& operator=(
const
DistLockedTask
&&) =
delete
;
57
58
~DistLockedTask
();
59
72
DistLockedTask
(
73
std::string name,
74
WorkerFunc worker_func,
75
std::shared_ptr<DistLockStrategyBase> strategy,
76
const
DistLockSettings
& settings = {},
77
DistLockWaitingMode
mode =
DistLockWaitingMode::kWait
,
78
DistLockRetryMode
retry_mode =
DistLockRetryMode::kRetry
,
79
logging::Level
base_log_level =
logging::Level::kInfo
80
);
81
83
DistLockedTask
(
84
engine::TaskProcessor& task_processor,
85
std::string name,
86
WorkerFunc worker_func,
87
std::shared_ptr<DistLockStrategyBase> strategy,
88
const
DistLockSettings
& settings = {},
89
DistLockWaitingMode
mode =
DistLockWaitingMode::kWait
,
90
DistLockRetryMode
retry_mode =
DistLockRetryMode::kRetry
,
91
logging::Level
base_log_level =
logging::Level::kInfo
92
);
93
96
std::optional<std::chrono::steady_clock::duration>
GetLockedDuration
()
const
;
97
98
void
Get() noexcept(false);
99
100
private:
101
DistLockedTask
(
engine
::
TaskProcessor
&,
std
::shared_ptr<impl::Locker>,
DistLockWaitingMode
);
102
103
std
::shared_ptr<impl::Locker> locker_ptr_;
104
};
105
106
}
// namespace dist_lock
107
108
USERVER_NAMESPACE_END
userver
dist_lock
dist_locked_task.hpp
Generated on
for userver by
Doxygen
1.17.0