1 #ifndef _library_threads__hpp__included__
2 #define _library_threads__hpp__included__
9 #include <condition_variable>
12 #include <boost/thread.hpp>
13 #include <boost/thread/locks.hpp>
19 typedef std::thread thread
;
20 typedef std::condition_variable cv
;
21 typedef std::mutex lock
;
22 typedef std::recursive_mutex rlock
;
23 typedef std::unique_lock
<std::mutex
> alock
;
24 typedef std::unique_lock
<std::recursive_mutex
> arlock
;
25 typedef std::chrono::microseconds ustime
;
26 typedef std::thread::id id
;
27 inline void cv_timed_wait(cv
& c
, alock
& m
, const ustime
& t
)
33 return std::this_thread::get_id();
36 typedef boost::thread thread
;
37 typedef boost::condition_variable cv
;
38 typedef boost::mutex lock
;
39 typedef boost::recursive_mutex rlock
;
40 typedef boost::unique_lock
<boost::mutex
> alock
;
41 typedef boost::unique_lock
<boost::recursive_mutex
> arlock
;
42 typedef boost::posix_time::microseconds ustime
;
43 typedef boost::thread::id id
;
44 inline void cv_timed_wait(cv
& c
, alock
& m
, const ustime
& t
)
50 return boost::this_thread::get_id();
55 * Lock multiple locks.
57 * The locks are always locked in address order. Duplicate locks are only locked once.
59 void lock_multiple(std::initializer_list
<lock
*> locks
);
61 * Unlock multiple locks.
63 * Duplicate locks are only unlocked once.
65 void unlock_multiple(std::initializer_list
<lock
*> locks
);
66 void unlock_multiple(std::vector
<lock
*> locks
);
71 alock_multiple(std::initializer_list
<lock
*> locks
)
73 _locks
= std::vector
<lock
*>(locks
);
78 unlock_multiple(_locks
);
81 std::vector
<lock
*> _locks
;