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_POSIX_SEMAPHORE_HPP
12 #define BOOST_INTERPROCESS_POSIX_SEMAPHORE_HPP
14 #ifndef BOOST_CONFIG_HPP
15 # include <boost/config.hpp>
18 #if defined(BOOST_HAS_PRAGMA_ONCE)
22 #include <boost/interprocess/detail/config_begin.hpp>
23 #include <boost/interprocess/detail/workaround.hpp>
25 #include <boost/interprocess/detail/posix_time_types_wrk.hpp>
26 #include <boost/interprocess/sync/posix/semaphore_wrapper.hpp>
29 namespace interprocess {
35 posix_semaphore(const posix_semaphore&);
36 posix_semaphore &operator= (const posix_semaphore &);
39 posix_semaphore(unsigned int initialCount)
40 { semaphore_init(&m_sem, initialCount); }
43 { semaphore_destroy(&m_sem); }
46 { semaphore_post(&m_sem); }
49 { semaphore_wait(&m_sem); }
52 { return semaphore_try_wait(&m_sem); }
54 bool timed_wait(const boost::posix_time::ptime &abs_time)
55 { return semaphore_timed_wait(&m_sem, abs_time); }
61 } //namespace ipcdetail {
62 } //namespace interprocess {
65 #include <boost/interprocess/detail/config_end.hpp>
67 #endif //#ifndef BOOST_INTERPROCESS_POSIX_SEMAPHORE_HPP