123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- #ifndef BOOST_INTERPROCESS_CONDITION_HPP
- #define BOOST_INTERPROCESS_CONDITION_HPP
- #ifndef BOOST_CONFIG_HPP
- # include <boost/config.hpp>
- #endif
- #
- #if defined(BOOST_HAS_PRAGMA_ONCE)
- # pragma once
- #endif
- #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
- #include <boost/interprocess/detail/config_begin.hpp>
- #include <boost/interprocess/detail/workaround.hpp>
- #include <boost/interprocess/sync/cv_status.hpp>
- #include <boost/interprocess/sync/interprocess_mutex.hpp>
- #include <boost/interprocess/sync/detail/locks.hpp>
- #include <boost/interprocess/timed_utils.hpp>
- #include <boost/interprocess/exceptions.hpp>
- #include <boost/limits.hpp>
- #include <boost/assert.hpp>
- #if !defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) && defined(BOOST_INTERPROCESS_POSIX_PROCESS_SHARED)
- #include <boost/interprocess/sync/posix/condition.hpp>
- #define BOOST_INTERPROCESS_CONDITION_USE_POSIX
- #elif !defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) && defined (BOOST_INTERPROCESS_WINDOWS)
- #include <boost/interprocess/sync/windows/condition.hpp>
- #define BOOST_INTERPROCESS_CONDITION_USE_WINAPI
- #else
-
- #include <boost/interprocess/sync/spin/condition.hpp>
- #endif
- #endif
- namespace boost {
- namespace interprocess {
- class named_condition;
- class interprocess_condition
- {
- #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
-
- interprocess_condition(const interprocess_condition &);
- interprocess_condition &operator=(const interprocess_condition &);
- friend class named_condition;
- #endif
- public:
-
- interprocess_condition()
- {}
-
-
- ~interprocess_condition()
- {}
-
-
- void notify_one()
- { m_condition.notify_one(); }
-
-
- void notify_all()
- { m_condition.notify_all(); }
-
-
-
- template <typename L>
- void wait(L& lock)
- {
- ipcdetail::internal_mutex_lock<L> internal_lock(lock);
- m_condition.wait(internal_lock);
- }
-
-
- template <typename L, typename Pr>
- void wait(L& lock, Pr pred)
- {
- ipcdetail::internal_mutex_lock<L> internal_lock(lock);
- m_condition.wait(internal_lock, pred);
- }
-
-
-
-
-
- template <typename L, class TimePoint>
- bool timed_wait(L& lock, const TimePoint &abs_time)
- {
- ipcdetail::internal_mutex_lock<L> internal_lock(lock);
- return m_condition.timed_wait(internal_lock, abs_time);
- }
-
-
-
- template <typename L, class TimePoint, typename Pr>
- bool timed_wait(L& lock, const TimePoint &abs_time, Pr pred)
- {
- ipcdetail::internal_mutex_lock<L> internal_lock(lock);
- return m_condition.timed_wait(internal_lock, abs_time, pred);
- }
-
-
- template <typename L, class TimePoint>
- cv_status wait_until(L& lock, const TimePoint &abs_time)
- { return this->timed_wait(lock, abs_time) ? cv_status::no_timeout : cv_status::timeout; }
-
-
- template <typename L, class TimePoint, typename Pr>
- bool wait_until(L& lock, const TimePoint &abs_time, Pr pred)
- { return this->timed_wait(lock, abs_time, pred); }
-
-
- template <typename L, class Duration>
- cv_status wait_for(L& lock, const Duration &dur)
- { return this->wait_until(lock, ipcdetail::duration_to_ustime(dur)); }
-
-
- template <typename L, class Duration, typename Pr>
- bool wait_for(L& lock, const Duration &dur, Pr pred)
- { return this->wait_until(lock, ipcdetail::duration_to_ustime(dur), pred); }
- #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
- private:
- #if defined(BOOST_INTERPROCESS_CONDITION_USE_POSIX)
- ipcdetail::posix_condition m_condition;
- #elif defined(BOOST_INTERPROCESS_CONDITION_USE_WINAPI)
- ipcdetail::winapi_condition m_condition;
- #else
- ipcdetail::spin_condition m_condition;
- #endif
- #endif
- };
- }
- }
- #include <boost/interprocess/detail/config_end.hpp>
- #endif
|