File indexing completed on 2026-09-13 08:49:34
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_INTERPROCESS_DETAIL_WINDOWS_CONDITION_HPP
0012 #define BOOST_INTERPROCESS_DETAIL_WINDOWS_CONDITION_HPP
0013
0014 #ifndef BOOST_CONFIG_HPP
0015 # include <boost/config.hpp>
0016 #endif
0017 0018 ">#
0019 #if defined(BOOST_HAS_PRAGMA_ONCE)
0020 # pragma once
0021 #endif
0022
0023 #include <boost/interprocess/detail/config_begin.hpp>
0024 #include <boost/interprocess/detail/workaround.hpp>
0025
0026 #include <boost/interprocess/sync/cv_status.hpp>
0027 #include <boost/interprocess/sync/interprocess_mutex.hpp>
0028 #include <boost/interprocess/sync/scoped_lock.hpp>
0029 #include <boost/interprocess/exceptions.hpp>
0030 #include <boost/interprocess/sync/windows/semaphore.hpp>
0031 #include <boost/interprocess/sync/windows/mutex.hpp>
0032 #include <boost/interprocess/timed_utils.hpp>
0033 #include <boost/interprocess/sync/detail/condition_algorithm_8a.hpp>
0034
0035
0036 namespace boost {
0037 namespace interprocess {
0038 namespace ipcdetail {
0039
0040 class winapi_condition
0041 {
0042 winapi_condition(const winapi_condition &);
0043 winapi_condition &operator=(const winapi_condition &);
0044
0045 public:
0046 winapi_condition()
0047 : m_condition_data()
0048 {}
0049
0050 ~winapi_condition()
0051 {
0052
0053
0054 this->notify_all();
0055 }
0056
0057 void notify_one()
0058 { m_condition_data.notify_one(); }
0059
0060 void notify_all()
0061 { m_condition_data.notify_all(); }
0062
0063 template <typename L>
0064 void wait(L& lock)
0065 { m_condition_data.wait(lock); }
0066
0067 template <typename L, typename Pr>
0068 void wait(L& lock, Pr pred)
0069 { m_condition_data.wait(lock, pred); }
0070
0071
0072 template <typename L, typename TimePoint>
0073 bool timed_wait(L& lock, const TimePoint &abs_time)
0074 { return m_condition_data.timed_wait(lock, abs_time); }
0075
0076 template <typename L, typename TimePoint, typename Pr>
0077 bool timed_wait(L& lock, const TimePoint &abs_time, Pr pred)
0078 { return m_condition_data.timed_wait(lock, abs_time, pred); }
0079
0080 template <typename L, class TimePoint>
0081 cv_status wait_until(L& lock, const TimePoint &abs_time)
0082 { return this->timed_wait(lock, abs_time) ? cv_status::no_timeout : cv_status::timeout; }
0083
0084 template <typename L, class TimePoint, typename Pr>
0085 bool wait_until(L& lock, const TimePoint &abs_time, Pr pred)
0086 { return this->timed_wait(lock, abs_time, pred); }
0087
0088 template <typename L, class Duration>
0089 cv_status wait_for(L& lock, const Duration &dur)
0090 { return this->wait_until(lock, duration_to_ustime(dur)); }
0091
0092 template <typename L, class Duration, typename Pr>
0093 bool wait_for(L& lock, const Duration &dur, Pr pred)
0094 { return this->wait_until(lock, duration_to_ustime(dur), pred); }
0095
0096 private:
0097
0098 struct condition_data
0099 {
0100 typedef unsigned int integer_type;
0101 typedef winapi_semaphore semaphore_type;
0102 typedef winapi_mutex mutex_type;
0103
0104 condition_data()
0105 : m_nwaiters_blocked(0)
0106 , m_nwaiters_gone(0)
0107 , m_nwaiters_to_unblock(0)
0108 , m_sem_block_queue(0)
0109 , m_sem_block_lock(1)
0110 , m_mtx_unblock_lock()
0111 {}
0112
0113 integer_type &get_nwaiters_blocked()
0114 { return m_nwaiters_blocked; }
0115
0116 integer_type &get_nwaiters_gone()
0117 { return m_nwaiters_gone; }
0118
0119 integer_type &get_nwaiters_to_unblock()
0120 { return m_nwaiters_to_unblock; }
0121
0122 semaphore_type &get_sem_block_queue()
0123 { return m_sem_block_queue; }
0124
0125 semaphore_type &get_sem_block_lock()
0126 { return m_sem_block_lock; }
0127
0128 mutex_type &get_mtx_unblock_lock()
0129 { return m_mtx_unblock_lock; }
0130
0131 integer_type m_nwaiters_blocked;
0132 integer_type m_nwaiters_gone;
0133 integer_type m_nwaiters_to_unblock;
0134 semaphore_type m_sem_block_queue;
0135 semaphore_type m_sem_block_lock;
0136 mutex_type m_mtx_unblock_lock;
0137 };
0138
0139 ipcdetail::condition_8a_wrapper<condition_data> m_condition_data;
0140 };
0141
0142 }
0143 }
0144 }
0145
0146 #include <boost/interprocess/detail/config_end.hpp>
0147
0148 #endif