123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- #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/creation_tags.hpp>
- #include <boost/interprocess/exceptions.hpp>
- #include <boost/interprocess/detail/interprocess_tester.hpp>
- #include <boost/interprocess/permissions.hpp>
- #include <boost/interprocess/detail/posix_time_types_wrk.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 create_only, const char *name, const permissions &perm = permissions());
-
-
-
-
-
-
- named_condition(open_or_create_t open_or_create, const char *name, const permissions &perm = permissions());
-
-
-
- named_condition(open_only_t open_only, const char *name);
-
-
-
- #if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) || defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
-
-
-
-
-
- named_condition(create_only_t create_only, const wchar_t *name, const permissions &perm = permissions());
-
-
-
-
-
-
-
-
-
- named_condition(open_or_create_t open_or_create, const wchar_t *name, const permissions &perm = permissions());
-
-
-
-
-
-
- named_condition(open_only_t open_only, 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>
- bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time);
-
-
-
- template <typename L, typename Pr>
- bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time, Pr 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>
- inline bool named_condition::timed_wait
- (L& lock, const boost::posix_time::ptime &abs_time)
- {
- ipcdetail::internal_mutex_lock<L> internal_lock(lock);
- return m_cond.timed_wait(internal_lock, abs_time);
- }
- template <typename L, typename Pr>
- inline bool named_condition::timed_wait
- (L& lock, const boost::posix_time::ptime &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
|