123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- #ifndef BOOST_INTERPROCESS_NAMED_CONDITION_HPP
- #define BOOST_INTERPROCESS_NAMED_CONDITION_HPP
- #ifndef BOOST_CONFIG_HPP
- # include <boost/config.hpp>
- #endif
- #
- #if defined(BOOST_HAS_PRAGMA_ONCE)
- # pragma once
- #endif
- #include <boost/interprocess/detail/config_begin.hpp>
- #include <boost/interprocess/detail/workaround.hpp>
- #include <boost/interprocess/sync/cv_status.hpp>
- #include <boost/interprocess/creation_tags.hpp>
- #include <boost/interprocess/exceptions.hpp>
- #include <boost/interprocess/timed_utils.hpp>
- #include <boost/interprocess/detail/interprocess_tester.hpp>
- #include <boost/interprocess/permissions.hpp>
- #include <boost/interprocess/sync/detail/locks.hpp>
- #if !defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) && defined (BOOST_INTERPROCESS_WINDOWS)
- #include <boost/interprocess/sync/windows/named_condition.hpp>
- #define BOOST_INTERPROCESS_NAMED_CONDITION_USE_WINAPI
- #else
- #include <boost/interprocess/sync/shm/named_condition.hpp>
- #endif
- namespace boost {
- namespace interprocess {
- #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
- namespace ipcdetail{ class interprocess_tester; }
- #endif
- class named_condition
- {
- #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
-
- named_condition();
- named_condition(const named_condition &);
- named_condition &operator=(const named_condition &);
- #endif
- public:
-
-
- named_condition(create_only_t, const char *name, const permissions &perm = permissions());
-
-
-
-
-
-
- named_condition(open_or_create_t, const char *name, const permissions &perm = permissions());
-
-
-
- named_condition(open_only_t, const char *name);
-
-
-
- #if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) || defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
-
-
-
-
-
- named_condition(create_only_t, const wchar_t *name, const permissions &perm = permissions());
-
-
-
-
-
-
-
-
-
- named_condition(open_or_create_t, const wchar_t *name, const permissions &perm = permissions());
-
-
-
-
-
-
- named_condition(open_only_t, const wchar_t *name);
- #endif
-
-
-
-
-
-
- ~named_condition();
-
-
- void notify_one();
-
-
- void notify_all();
-
-
-
- template <typename L>
- void wait(L& lock);
-
-
- template <typename L, typename Pr>
- void wait(L& lock, Pr pred);
-
-
-
-
-
- template <typename L, class TimePoint>
- bool timed_wait(L& lock, const TimePoint &abs_time);
-
-
-
- template <typename L, class TimePoint, typename Pr>
- bool timed_wait(L& lock, const TimePoint &abs_time, Pr 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); }
-
-
- static bool remove(const char *name);
- #if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) || defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
-
-
-
-
-
- static bool remove(const wchar_t *name);
- #endif
- #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
- private:
- #if defined(BOOST_INTERPROCESS_NAMED_CONDITION_USE_WINAPI)
- typedef ipcdetail::winapi_named_condition condition_type;
- #else
- typedef ipcdetail::shm_named_condition condition_type;
- #endif
- condition_type m_cond;
- friend class ipcdetail::interprocess_tester;
- void dont_close_on_destruction()
- { ipcdetail::interprocess_tester::dont_close_on_destruction(m_cond); }
- #endif
- };
- #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
- inline named_condition::~named_condition()
- {}
- inline named_condition::named_condition(create_only_t, const char *name, const permissions &perm)
- : m_cond(create_only_t(), name, perm)
- {}
- inline named_condition::named_condition(open_or_create_t, const char *name, const permissions &perm)
- : m_cond(open_or_create_t(), name, perm)
- {}
- inline named_condition::named_condition(open_only_t, const char *name)
- : m_cond(open_only_t(), name)
- {}
- #if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) || defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
- inline named_condition::named_condition(create_only_t, const wchar_t *name, const permissions &perm)
- : m_cond(create_only_t(), name, perm)
- {}
- inline named_condition::named_condition(open_or_create_t, const wchar_t *name, const permissions &perm)
- : m_cond(open_or_create_t(), name, perm)
- {}
- inline named_condition::named_condition(open_only_t, const wchar_t *name)
- : m_cond(open_only_t(), name)
- {}
- #endif
- inline void named_condition::notify_one()
- { m_cond.notify_one(); }
- inline void named_condition::notify_all()
- { m_cond.notify_all(); }
- template <typename L>
- inline void named_condition::wait(L& lock)
- {
- ipcdetail::internal_mutex_lock<L> internal_lock(lock);
- m_cond.wait(internal_lock);
- }
- template <typename L, typename Pr>
- inline void named_condition::wait(L& lock, Pr pred)
- {
- ipcdetail::internal_mutex_lock<L> internal_lock(lock);
- m_cond.wait(internal_lock, pred);
- }
- template <typename L, typename TimePoint>
- inline bool named_condition::timed_wait
- (L& lock, const TimePoint &abs_time)
- {
- ipcdetail::internal_mutex_lock<L> internal_lock(lock);
- return m_cond.timed_wait(internal_lock, abs_time);
- }
- template <typename L, typename TimePoint, typename Pr>
- inline bool named_condition::timed_wait
- (L& lock, const TimePoint &abs_time, Pr pred)
- {
- ipcdetail::internal_mutex_lock<L> internal_lock(lock);
- return m_cond.timed_wait(internal_lock, abs_time, pred);
- }
- inline bool named_condition::remove(const char *name)
- {
- return condition_type::remove(name);
- }
- #if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) || defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
- inline bool named_condition::remove(const wchar_t *name)
- {
- return condition_type::remove(name);
- }
- #endif
- #endif
- }
- }
- #include <boost/interprocess/detail/config_end.hpp>
- #endif
|