YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
shared_timed_mutex.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <yaclib_std/chrono>
7
8namespace yaclib::detail {
9
10// TODO(myannyax) Make mixins for mutex like types, here we want:
11// private Impl, public SharedMutex<Impl>, public TimedMutex<Impl>
12template <typename Impl>
13class SharedTimedMutex : public SharedMutex<Impl> {
14 using Base = SharedMutex<Impl>;
15
16 public:
17 using Base::Base;
18
19 template <typename Rep, typename Period>
20 bool try_lock_for(const std::chrono::duration<Rep, Period>& timeout_duration) {
21 YACLIB_INJECT_FAULT(auto r = Impl::try_lock_for(timeout_duration));
22 return r;
23 }
24
25 template <typename Clock, typename Duration>
26 bool try_lock_until(const std::chrono::time_point<Clock, Duration>& timeout_time) {
27 YACLIB_INJECT_FAULT(auto r = Impl::try_lock_until(timeout_time));
28 return r;
29 }
30
31 template <typename Rep, typename Period>
32 bool try_lock_shared_for(const std::chrono::duration<Rep, Period>& timeout_duration) {
33 YACLIB_INJECT_FAULT(auto r = Impl::try_lock_shared_for(timeout_duration));
34 return r;
35 }
36
37 template <typename Clock, typename Duration>
38 bool try_lock_shared_until(const std::chrono::time_point<Clock, Duration>& timeout_time) {
39 YACLIB_INJECT_FAULT(auto r = Impl::try_lock_shared_until(timeout_time));
40 return r;
41 }
42};
43
44} // namespace yaclib::detail
bool try_lock_until(const std::chrono::time_point< Clock, Duration > &timeout_time)
bool try_lock_shared_until(const std::chrono::time_point< Clock, Duration > &timeout_time)
bool try_lock_shared_for(const std::chrono::duration< Rep, Period > &timeout_duration)
bool try_lock_for(const std::chrono::duration< Rep, Period > &timeout_duration)
#define YACLIB_INJECT_FAULT(statement)
Definition inject.hpp:20
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25