Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/interprocess/sync/posix/named_mutex.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_MUTEX_HPP | |
12 #define BOOST_INTERPROCESS_POSIX_NAMED_MUTEX_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 #include <boost/interprocess/creation_tags.hpp> | |
21 #include <boost/interprocess/exceptions.hpp> | |
22 #include <boost/interprocess/detail/interprocess_tester.hpp> | |
23 #include <boost/interprocess/permissions.hpp> | |
24 | |
25 #include <boost/interprocess/sync/posix/named_semaphore.hpp> | |
26 | |
27 namespace boost { | |
28 namespace interprocess { | |
29 namespace ipcdetail { | |
30 | |
31 class named_condition; | |
32 | |
33 class posix_named_mutex | |
34 { | |
35 /// @cond | |
36 | |
37 posix_named_mutex(); | |
38 posix_named_mutex(const posix_named_mutex &); | |
39 posix_named_mutex &operator=(const posix_named_mutex &); | |
40 friend class named_condition; | |
41 /// @endcond | |
42 | |
43 public: | |
44 posix_named_mutex(create_only_t create_only, const char *name, const permissions &perm = permissions()); | |
45 | |
46 posix_named_mutex(open_or_create_t open_or_create, const char *name, const permissions &perm = permissions()); | |
47 | |
48 posix_named_mutex(open_only_t open_only, const char *name); | |
49 | |
50 ~posix_named_mutex(); | |
51 | |
52 void unlock(); | |
53 void lock(); | |
54 bool try_lock(); | |
55 bool timed_lock(const boost::posix_time::ptime &abs_time); | |
56 static bool remove(const char *name); | |
57 | |
58 /// @cond | |
59 private: | |
60 friend class interprocess_tester; | |
61 void dont_close_on_destruction(); | |
62 | |
63 posix_named_semaphore m_sem; | |
64 /// @endcond | |
65 }; | |
66 | |
67 /// @cond | |
68 | |
69 inline posix_named_mutex::posix_named_mutex(create_only_t, const char *name, const permissions &perm) | |
70 : m_sem(create_only, name, 1, perm) | |
71 {} | |
72 | |
73 inline posix_named_mutex::posix_named_mutex(open_or_create_t, const char *name, const permissions &perm) | |
74 : m_sem(open_or_create, name, 1, perm) | |
75 {} | |
76 | |
77 inline posix_named_mutex::posix_named_mutex(open_only_t, const char *name) | |
78 : m_sem(open_only, name) | |
79 {} | |
80 | |
81 inline void posix_named_mutex::dont_close_on_destruction() | |
82 { interprocess_tester::dont_close_on_destruction(m_sem); } | |
83 | |
84 inline posix_named_mutex::~posix_named_mutex() | |
85 {} | |
86 | |
87 inline void posix_named_mutex::lock() | |
88 { m_sem.wait(); } | |
89 | |
90 inline void posix_named_mutex::unlock() | |
91 { m_sem.post(); } | |
92 | |
93 inline bool posix_named_mutex::try_lock() | |
94 { return m_sem.try_wait(); } | |
95 | |
96 inline bool posix_named_mutex::timed_lock(const boost::posix_time::ptime &abs_time) | |
97 { | |
98 if(abs_time == boost::posix_time::pos_infin){ | |
99 this->lock(); | |
100 return true; | |
101 } | |
102 return m_sem.timed_wait(abs_time); | |
103 } | |
104 | |
105 inline bool posix_named_mutex::remove(const char *name) | |
106 { return posix_named_semaphore::remove(name); } | |
107 | |
108 /// @endcond | |
109 | |
110 } //namespace ipcdetail { | |
111 } //namespace interprocess { | |
112 } //namespace boost { | |
113 | |
114 #include <boost/interprocess/detail/config_end.hpp> | |
115 | |
116 #endif //BOOST_INTERPROCESS_POSIX_NAMED_MUTEX_HPP |