function template allows you to try and lock a set of lockable objects
in one go, so either they are all locked or none are locked.
template< typename LockableType1,typename... LockableType2> int try_lock(LockableType1& m1,LockableType2& m2...);
The types of the supplied lockable objects
shall conform to the
Tries to acquires a lock on each of the supplied lockable objects
m2, ... by calling
on each in turn. If a call to
or throws an exception, and locks already acquired are released by
on the corresponding lockable object.
-1 if all locks were acquired (each call to
otherwise the zero-based index of object for which the call to
If the function returns -1, the current thread owns a lock on each of the supplied lockable objects. Otherwise, any locks acquired by this call have been released.
Any exceptions thrown by the calls to
If an exception propagates out of the call to
shall have been called for any of the objects
m2, ... for which
a lock has been acquired in the function by a call to
On compilers that don't support variadic templates, an overloaded set of function templates is provided that supports passing of up to 5 arguments.