annotate DEPENDENCIES/generic/include/boost/interprocess/sync/posix/semaphore.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
rev   line source
Chris@16 1 //////////////////////////////////////////////////////////////////////////////
Chris@16 2 //
Chris@16 3 // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
Chris@16 4 // Software License, Version 1.0. (See accompanying file
Chris@16 5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 //
Chris@16 7 // See http://www.boost.org/libs/interprocess for documentation.
Chris@16 8 //
Chris@16 9 //////////////////////////////////////////////////////////////////////////////
Chris@16 10
Chris@16 11 #ifndef BOOST_INTERPROCESS_POSIX_SEMAPHORE_HPP
Chris@16 12 #define BOOST_INTERPROCESS_POSIX_SEMAPHORE_HPP
Chris@16 13
Chris@16 14 #if (defined _MSC_VER) && (_MSC_VER >= 1200)
Chris@16 15 # pragma once
Chris@16 16 #endif
Chris@16 17
Chris@16 18 #include <boost/interprocess/detail/config_begin.hpp>
Chris@16 19 #include <boost/interprocess/detail/workaround.hpp>
Chris@16 20
Chris@16 21 #include <boost/interprocess/detail/posix_time_types_wrk.hpp>
Chris@16 22 #include <boost/interprocess/sync/posix/semaphore_wrapper.hpp>
Chris@16 23
Chris@16 24 namespace boost {
Chris@16 25 namespace interprocess {
Chris@16 26 namespace ipcdetail {
Chris@16 27
Chris@16 28 class posix_semaphore
Chris@16 29 {
Chris@16 30 posix_semaphore();
Chris@16 31 posix_semaphore(const posix_semaphore&);
Chris@16 32 posix_semaphore &operator= (const posix_semaphore &);
Chris@16 33
Chris@16 34 public:
Chris@16 35 posix_semaphore(unsigned int initialCount)
Chris@16 36 { semaphore_init(&m_sem, initialCount); }
Chris@16 37
Chris@16 38 ~posix_semaphore()
Chris@16 39 { semaphore_destroy(&m_sem); }
Chris@16 40
Chris@16 41 void post()
Chris@16 42 { semaphore_post(&m_sem); }
Chris@16 43
Chris@16 44 void wait()
Chris@16 45 { semaphore_wait(&m_sem); }
Chris@16 46
Chris@16 47 bool try_wait()
Chris@16 48 { return semaphore_try_wait(&m_sem); }
Chris@16 49
Chris@16 50 bool timed_wait(const boost::posix_time::ptime &abs_time)
Chris@16 51 { return semaphore_timed_wait(&m_sem, abs_time); }
Chris@16 52
Chris@16 53 private:
Chris@16 54 sem_t m_sem;
Chris@16 55 };
Chris@16 56
Chris@16 57 } //namespace ipcdetail {
Chris@16 58 } //namespace interprocess {
Chris@16 59 } //namespace boost {
Chris@16 60
Chris@16 61 #include <boost/interprocess/detail/config_end.hpp>
Chris@16 62
Chris@16 63 #endif //#ifndef BOOST_INTERPROCESS_POSIX_SEMAPHORE_HPP