![]() |
Home | Libraries | People | FAQ | More |
// #include <boost/thread/locks.hpp> // #include <boost/thread/lock_algorithms.hpp> namespace boost { template<typename Lockable1,typename Lockable2> void lock(Lockable1& l1,Lockable2& l2); template<typename Lockable1,typename Lockable2,typename Lockable3> void lock(Lockable1& l1,Lockable2& l2,Lockable3& l3); template<typename Lockable1,typename Lockable2,typename Lockable3,typename Lockable4> void lock(Lockable1& l1,Lockable2& l2,Lockable3& l3,Lockable4& l4); template<typename Lockable1,typename Lockable2,typename Lockable3,typename Lockable4,typename Lockable5> void lock(Lockable1& l1,Lockable2& l2,Lockable3& l3,Lockable4& l4,Lockable5& l5); }
Locks the Lockable
objects supplied
as arguments in an unspecified and indeterminate order in a way that
avoids deadlock. It is safe to call this function concurrently from
multiple threads with the same mutexes (or other lockable objects)
in different orders without risk of deadlock. If any of the lock()
or try_lock()
operations on the supplied Lockable
objects throws
an exception any locks acquired by the function will be released
before the function exits.
Any exceptions thrown by calling lock()
or try_lock()
on the supplied Lockable
objects.
All the supplied Lockable
objects are locked
by the calling thread.
template<typename ForwardIterator> void lock(ForwardIterator begin,ForwardIterator end);
The value_type
of
ForwardIterator
must
implement the Lockable
concept
Locks all the Lockable
objects in the
supplied range in an unspecified and indeterminate order in a way
that avoids deadlock. It is safe to call this function concurrently
from multiple threads with the same mutexes (or other lockable objects)
in different orders without risk of deadlock. If any of the lock()
or try_lock()
operations on the Lockable
objects in the
supplied range throws an exception any locks acquired by the function
will be released before the function exits.
Any exceptions thrown by calling lock()
or try_lock()
on the supplied Lockable
objects.
All the Lockable
objects in the
supplied range are locked by the calling thread.
template<typename Lockable1,typename Lockable2> int try_lock(Lockable1& l1,Lockable2& l2); template<typename Lockable1,typename Lockable2,typename Lockable3> int try_lock(Lockable1& l1,Lockable2& l2,Lockable3& l3); template<typename Lockable1,typename Lockable2,typename Lockable3,typename Lockable4> int try_lock(Lockable1& l1,Lockable2& l2,Lockable3& l3,Lockable4& l4); template<typename Lockable1,typename Lockable2,typename Lockable3,typename Lockable4,typename Lockable5> int try_lock(Lockable1& l1,Lockable2& l2,Lockable3& l3,Lockable4& l4,Lockable5& l5);
Calls try_lock()
on each of the Lockable
objects supplied
as arguments. If any of the calls to try_lock()
returns false
then all
locks acquired are released and the zero-based index of the failed
lock is returned.
If any of the try_lock()
operations on the supplied Lockable
objects throws
an exception any locks acquired by the function will be released
before the function exits.
-1
if all the supplied Lockable
objects are now
locked by the calling thread, the zero-based index of the object
which could not be locked otherwise.
Any exceptions thrown by calling try_lock()
on the supplied Lockable
objects.
If the function returns -1
, all the supplied Lockable
objects are locked
by the calling thread. Otherwise any locks acquired by this function
will have been released.
template<typename ForwardIterator> ForwardIterator try_lock(ForwardIterator begin,ForwardIterator end);
The value_type
of
ForwardIterator
must
implement the Lockable
concept
Calls try_lock()
on each of the Lockable
objects in the
supplied range. If any of the calls to try_lock()
returns false
then all
locks acquired are released and an iterator referencing the failed
lock is returned.
If any of the try_lock()
operations on the supplied Lockable
objects throws
an exception any locks acquired by the function will be released
before the function exits.
end
if all the supplied
Lockable
objects are now
locked by the calling thread, an iterator referencing the object
which could not be locked otherwise.
Any exceptions thrown by calling try_lock()
on the supplied Lockable
objects.
If the function returns end
then all the Lockable
objects in the
supplied range are locked by the calling thread, otherwise all locks
acquired by the function have been released.