8 typedef ::resumef::detail::_awaker<mutex_impl> mutex_awaker;
9 typedef std::shared_ptr<mutex_awaker> mutex_awaker_ptr;
11 struct mutex_impl :
public std::enable_shared_from_this<mutex_impl>
15 typedef std::recursive_mutex lock_type;
17 std::list<mutex_awaker_ptr> _awakes;
18 mutex_awaker_ptr _owner;
24 bool lock_(
const mutex_awaker_ptr& awaker);
25 bool try_lock_(
const mutex_awaker_ptr& awaker);
28 template<
class callee_t,
class dummy_t = std::enable_if<!std::is_same<std::remove_cv_t<callee_t>, mutex_awaker_ptr>::value>>
29 decltype(
auto) lock(callee_t&& awaker, dummy_t* dummy_ =
nullptr)
32 return lock_(std::make_shared<mutex_awaker>(std::forward<callee_t>(awaker)));
36 mutex_impl(
const mutex_impl&) =
delete;
37 mutex_impl(mutex_impl&&) =
delete;
38 mutex_impl& operator = (
const mutex_impl&) =
delete;
39 mutex_impl& operator = (mutex_impl&&) =
delete;
47 typedef std::shared_ptr<detail::mutex_impl> lock_impl_ptr;
48 typedef std::weak_ptr<detail::mutex_impl> lock_impl_wptr;
49 typedef std::chrono::system_clock clock_type;
51 lock_impl_ptr _locker;
61 future_t<bool> lock()
const;
62 bool try_lock()
const;
80 mutex_t(
const mutex_t&) =
default;
81 mutex_t(mutex_t&&) =
default;
82 mutex_t& operator = (
const mutex_t&) =
default;
83 mutex_t& operator = (mutex_t&&) =
default;
85 inline future_t<bool> try_lock_for_(
const clock_type::duration& dt)
const
87 return try_lock_until_(clock_type::now() + dt);
89 future_t<bool> try_lock_until_(
const clock_type::time_point& tp)
const;