comparison 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
comparison
equal deleted inserted replaced
15:663ca0da4350 16:2665513ce2d3
1 //////////////////////////////////////////////////////////////////////////////
2 //
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)
6 //
7 // See http://www.boost.org/libs/interprocess for documentation.
8 //
9 //////////////////////////////////////////////////////////////////////////////
10
11 #ifndef BOOST_INTERPROCESS_POSIX_SEMAPHORE_HPP
12 #define BOOST_INTERPROCESS_POSIX_SEMAPHORE_HPP
13
14 #if (defined _MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif
17
18 #include <boost/interprocess/detail/config_begin.hpp>
19 #include <boost/interprocess/detail/workaround.hpp>
20
21 #include <boost/interprocess/detail/posix_time_types_wrk.hpp>
22 #include <boost/interprocess/sync/posix/semaphore_wrapper.hpp>
23
24 namespace boost {
25 namespace interprocess {
26 namespace ipcdetail {
27
28 class posix_semaphore
29 {
30 posix_semaphore();
31 posix_semaphore(const posix_semaphore&);
32 posix_semaphore &operator= (const posix_semaphore &);
33
34 public:
35 posix_semaphore(unsigned int initialCount)
36 { semaphore_init(&m_sem, initialCount); }
37
38 ~posix_semaphore()
39 { semaphore_destroy(&m_sem); }
40
41 void post()
42 { semaphore_post(&m_sem); }
43
44 void wait()
45 { semaphore_wait(&m_sem); }
46
47 bool try_wait()
48 { return semaphore_try_wait(&m_sem); }
49
50 bool timed_wait(const boost::posix_time::ptime &abs_time)
51 { return semaphore_timed_wait(&m_sem, abs_time); }
52
53 private:
54 sem_t m_sem;
55 };
56
57 } //namespace ipcdetail {
58 } //namespace interprocess {
59 } //namespace boost {
60
61 #include <boost/interprocess/detail/config_end.hpp>
62
63 #endif //#ifndef BOOST_INTERPROCESS_POSIX_SEMAPHORE_HPP