The jss::scoped_lock
class template provides a basic lock ownership wrapper. It is directly
equivalent to the jss::lock_guard
class template, except
it uses the name used by the C++17 standard. The type of mutex being locked
is specified by template parameter Mutex
,
and must meet the Lockable
requirements. The specified mutex is locked in the constructor and unlocked
in the destructor. This provides a simple means of locking a mutex for
a block of code and ensuring that the mutex is unlocked when the block
is left, whether that is by running off the end, by the use of a control
flow statement such as break
or return
, or by throwing
an exception.
Instances of jss::scoped_lock
are neither MoveConstructible
, CopyConstructible
or CopyAssignable
.
template <class ... LockableTypes> class scoped_lock { public: typedef LockableTypes mutex_type; // If LockableTypes is a single type explicit scoped_lock(LockableTypes& ... m); scoped_lock(LockableTypes& ... m, adopt_lock_t); ~scoped_lock(); scoped_lock(scoped_lock const& ) = delete; scoped_lock& operator=( scoped_lock const& ) = delete; };
#include <jss/guards.hpp>