10#include <userver/engine/deadline.hpp>
11#include <userver/engine/impl/wait_list_fwd.hpp>
13USERVER_NAMESPACE_BEGIN
34class SingleWaitingTaskMutex
final {
36 SingleWaitingTaskMutex();
37 ~SingleWaitingTaskMutex();
39 SingleWaitingTaskMutex(
const SingleWaitingTaskMutex&) =
delete;
40 SingleWaitingTaskMutex(SingleWaitingTaskMutex&&) =
delete;
41 SingleWaitingTaskMutex& operator=(
const SingleWaitingTaskMutex&) =
delete;
42 SingleWaitingTaskMutex& operator=(SingleWaitingTaskMutex&&) =
delete;
58 template <
typename Rep,
typename Period>
59 bool try_lock_for(
const std::chrono::duration<Rep, Period>&);
61 template <
typename Clock,
typename Duration>
62 bool try_lock_until(
const std::chrono::time_point<Clock, Duration>&);
64 bool try_lock_until(Deadline deadline);
69 utils::FastPimpl<Impl, 32, 16> impl_;
72template <
typename Rep,
typename Period>
73bool SingleWaitingTaskMutex::try_lock_for(
74 const std::chrono::duration<Rep, Period>& duration) {
75 return try_lock_until(Deadline::FromDuration(duration));
78template <
typename Clock,
typename Duration>
79bool SingleWaitingTaskMutex::try_lock_until(
80 const std::chrono::time_point<Clock, Duration>& until) {
81 return try_lock_until(Deadline::FromTimePoint(until));