1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/interprocess for documentation.
9 //////////////////////////////////////////////////////////////////////////////
11 #ifndef BOOST_INTERPROCESS_DETAIL_WINDOWS_CONDITION_HPP
12 #define BOOST_INTERPROCESS_DETAIL_WINDOWS_CONDITION_HPP
18 #include <boost/interprocess/detail/config_begin.hpp>
19 #include <boost/interprocess/detail/workaround.hpp>
20 #include <boost/interprocess/detail/posix_time_types_wrk.hpp>
22 #include <boost/interprocess/sync/interprocess_mutex.hpp>
23 #include <boost/interprocess/sync/scoped_lock.hpp>
24 #include <boost/interprocess/exceptions.hpp>
25 #include <boost/interprocess/sync/windows/semaphore.hpp>
26 #include <boost/interprocess/sync/windows/mutex.hpp>
27 #include <boost/interprocess/sync/detail/condition_algorithm_8a.hpp>
31 namespace interprocess {
34 class windows_condition
36 windows_condition(const windows_condition &);
37 windows_condition &operator=(const windows_condition &);
46 //Notify all waiting threads
47 //to allow POSIX semantics on condition destruction
52 { m_condition_data.notify_one(); }
55 { m_condition_data.notify_all(); }
58 bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time)
59 { return m_condition_data.timed_wait(lock, abs_time); }
61 template <typename L, typename Pr>
62 bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time, Pr pred)
63 { return m_condition_data.timed_wait(lock, abs_time, pred); }
67 { m_condition_data.wait(lock); }
69 template <typename L, typename Pr>
70 void wait(L& lock, Pr pred)
71 { m_condition_data.wait(lock, pred); }
77 typedef boost::int32_t integer_type;
78 typedef windows_semaphore semaphore_type;
79 typedef windows_mutex mutex_type;
82 : m_nwaiters_blocked(0)
84 , m_nwaiters_to_unblock(0)
85 , m_sem_block_queue(0)
87 , m_mtx_unblock_lock()
90 integer_type &get_nwaiters_blocked()
91 { return m_nwaiters_blocked; }
93 integer_type &get_nwaiters_gone()
94 { return m_nwaiters_gone; }
96 integer_type &get_nwaiters_to_unblock()
97 { return m_nwaiters_to_unblock; }
99 semaphore_type &get_sem_block_queue()
100 { return m_sem_block_queue; }
102 semaphore_type &get_sem_block_lock()
103 { return m_sem_block_lock; }
105 mutex_type &get_mtx_unblock_lock()
106 { return m_mtx_unblock_lock; }
108 boost::int32_t m_nwaiters_blocked;
109 boost::int32_t m_nwaiters_gone;
110 boost::int32_t m_nwaiters_to_unblock;
111 windows_semaphore m_sem_block_queue;
112 windows_semaphore m_sem_block_lock;
113 windows_mutex m_mtx_unblock_lock;
116 ipcdetail::condition_8a_wrapper<condition_data> m_condition_data;
119 } //namespace ipcdetail
120 } //namespace interprocess
123 #include <boost/interprocess/detail/config_end.hpp>
125 #endif //BOOST_INTERPROCESS_DETAIL_WINDOWS_CONDITION_HPP