25 #include <libcopp/utils/config/libcopp_build_features.h>
27 LIBCOPP_COPP_NAMESPACE_BEGIN
31 template <
typename TLock>
39 template <
typename TLock>
41 inline bool operator()(TLock &lock)
const noexcept {
return lock.try_lock(); }
44 template <
typename TLock>
46 inline void operator()(TLock &lock)
const noexcept { lock.unlock(); }
49 template <
typename TLock>
51 inline bool operator()(TLock &lock)
const noexcept {
return lock.try_unlock(); }
54 template <
typename TLock>
62 template <
typename TLock>
64 inline void operator()(TLock &lock)
const noexcept { lock.read_unlock(); }
67 template <
typename TLock>
75 template <
typename TLock>
77 inline void operator()(TLock &lock)
const noexcept { lock.write_unlock(); }
81 template <
typename TLock,
typename TLockAct = detail::default_lock_action<TLock>,
82 typename TUnlockAct = detail::default_unlock_action<TLock> >
94 if (lock_flag_ != other.lock_flag_) {
98 lock_flag_ = other.lock_flag_;
103 if (
false == TLockAct()(lock)) {
104 lock_flag_ =
nullptr;
109 if (
nullptr != lock_flag_) {
110 TUnlockAct()(*lock_flag_);
117 if (
nullptr != lock_flag_) {
119 lock_flag_ =
nullptr;
120 TUnlockAct()(*value);
132 template <
typename TLock>
134 :
public lock_holder<TLock, detail::default_read_lock_action<TLock>, detail::default_read_unlock_action<TLock> > {
137 :
lock_holder<TLock,
detail::default_read_lock_action<TLock>,
detail::default_read_unlock_action<TLock> >(lock) {}
140 template <
typename TLock>
142 :
public lock_holder<TLock, detail::default_write_lock_action<TLock>, detail::default_write_unlock_action<TLock> > {
150 LIBCOPP_COPP_NAMESPACE_END
lock_holder(const lock_holder &)=delete
lock_holder(lock_holder &&other)
bool is_available() const noexcept
lock_holder & operator=(lock_holder &&other) noexcept
lock_holder & operator=(const lock_holder &)=delete
read_lock_holder(TLock &lock)
write_lock_holder(TLock &lock)
bool operator()(TLock &lock) const noexcept
bool operator()(TLock &lock) const noexcept
void operator()(TLock &lock) const noexcept
bool operator()(TLock &lock) const noexcept
bool operator()(TLock &lock) const noexcept
void operator()(TLock &lock) const noexcept
bool operator()(TLock &lock) const noexcept
void operator()(TLock &lock) const noexcept