10#include <userver/engine/deadline.hpp>
11#include <userver/engine/impl/wait_list_fwd.hpp>
13USERVER_NAMESPACE_BEGIN
32class SingleWaitingTaskMutex
final {
34 SingleWaitingTaskMutex();
35 ~SingleWaitingTaskMutex();
37 SingleWaitingTaskMutex(
const SingleWaitingTaskMutex&) =
delete;
38 SingleWaitingTaskMutex(SingleWaitingTaskMutex&&) =
delete;
39 SingleWaitingTaskMutex& operator=(
const SingleWaitingTaskMutex&) =
delete;
40 SingleWaitingTaskMutex& operator=(SingleWaitingTaskMutex&&) =
delete;
57 template <
typename Rep,
typename Period>
58 bool try_lock_for(
const std::chrono::duration<Rep, Period>&);
60 template <
typename Clock,
typename Duration>
61 bool try_lock_until(
const std::chrono::time_point<Clock, Duration>&);
63 bool try_lock_until(Deadline deadline);
68 utils::FastPimpl<Impl, 32, 16> impl_;
71template <
typename Rep,
typename Period>
72bool SingleWaitingTaskMutex::try_lock_for(
73 const std::chrono::duration<Rep, Period>& duration) {
74 return try_lock_until(Deadline::FromDuration(duration));
77template <
typename Clock,
typename Duration>
78bool SingleWaitingTaskMutex::try_lock_until(
79 const std::chrono::time_point<Clock, Duration>& until) {
80 return try_lock_until(Deadline::FromTimePoint(until));