1
0
mirror of https://github.com/Zygo/bees.git synced 2025-05-18 13:55:44 +02:00

crucible: lockset: add LockSet<T>::Lock make_lock

Before:  decltype(foo)::Lock lock(foo, key);

After:   auto lock = foo.make_lock(key);

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
Zygo Blaxell 2017-01-13 00:49:03 -05:00
parent be1aa049c6
commit 9cb48c35b9

View File

@ -63,6 +63,7 @@ namespace crucible {
bool try_lock(); bool try_lock();
}; };
Lock make_lock(const key_type &name, bool start_locked = true);
}; };
template <class T> template <class T>
@ -215,7 +216,7 @@ namespace crucible {
template <class T> template <class T>
LockSet<T>::Lock::Lock(Lock &&that) : LockSet<T>::Lock::Lock(Lock &&that) :
m_lockset(that.lockset), m_lockset(that.m_lockset),
m_name(that.m_name), m_name(that.m_name),
m_locked(that.m_locked) m_locked(that.m_locked)
{ {
@ -236,6 +237,13 @@ namespace crucible {
return *this; return *this;
} }
template <class T>
typename LockSet<T>::Lock
LockSet<T>::make_lock(const key_type &name, bool start_locked)
{
return Lock(*this, name, start_locked);
}
} }
#endif // CRUCIBLE_LOCKSET_H #endif // CRUCIBLE_LOCKSET_H