Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/interprocess/sync/posix/named_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_NAMED_CONDITION_HPP | |
12 #define BOOST_INTERPROCESS_POSIX_NAMED_CONDITION_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/sync/posix/semaphore_wrapper.hpp> | |
22 | |
23 namespace boost { | |
24 namespace interprocess { | |
25 | |
26 /// @cond | |
27 namespace ipcdetail{ class interprocess_tester; } | |
28 /// @endcond | |
29 | |
30 namespace ipcdetail { | |
31 | |
32 class posix_named_semaphore | |
33 { | |
34 posix_named_semaphore(); | |
35 posix_named_semaphore(const posix_named_semaphore&); | |
36 posix_named_semaphore &operator= (const posix_named_semaphore &); | |
37 | |
38 public: | |
39 posix_named_semaphore | |
40 (create_only_t, const char *name, unsigned int initialCount, const permissions &perm = permissions()) | |
41 { semaphore_open(mp_sem, DoCreate, name, initialCount, perm); } | |
42 | |
43 posix_named_semaphore(open_or_create_t, const char *name, unsigned int initialCount, const permissions &perm = permissions()) | |
44 { semaphore_open(mp_sem, DoOpenOrCreate, name, initialCount, perm); } | |
45 | |
46 posix_named_semaphore(open_only_t, const char *name) | |
47 { semaphore_open(mp_sem, DoOpen, name); } | |
48 | |
49 ~posix_named_semaphore() | |
50 { | |
51 if(mp_sem != BOOST_INTERPROCESS_POSIX_SEM_FAILED) | |
52 semaphore_close(mp_sem); | |
53 } | |
54 | |
55 void post() | |
56 { semaphore_post(mp_sem); } | |
57 | |
58 void wait() | |
59 { semaphore_wait(mp_sem); } | |
60 | |
61 bool try_wait() | |
62 { return semaphore_try_wait(mp_sem); } | |
63 | |
64 bool timed_wait(const boost::posix_time::ptime &abs_time) | |
65 { return semaphore_timed_wait(mp_sem, abs_time); } | |
66 | |
67 static bool remove(const char *name) | |
68 { return semaphore_unlink(name); } | |
69 | |
70 private: | |
71 friend class ipcdetail::interprocess_tester; | |
72 void dont_close_on_destruction() | |
73 { mp_sem = BOOST_INTERPROCESS_POSIX_SEM_FAILED; } | |
74 | |
75 sem_t *mp_sem; | |
76 }; | |
77 | |
78 } //namespace ipcdetail { | |
79 } //namespace interprocess { | |
80 } //namespace boost { | |
81 | |
82 #include <boost/interprocess/detail/config_end.hpp> | |
83 | |
84 #endif //#ifndef BOOST_INTERPROCESS_POSIX_NAMED_CONDITION_HPP |