1 | 1 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,142 @@ |
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_SEMAPHORE_HPP |
|
12 |
+#define BOOST_INTERPROCESS_SEMAPHORE_HPP |
|
13 |
+ |
|
14 |
+#if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) |
|
15 |
+ |
|
16 |
+#ifndef BOOST_CONFIG_HPP |
|
17 |
+# include <boost/config.hpp> |
|
18 |
+#endif |
|
19 |
+# |
|
20 |
+#if defined(BOOST_HAS_PRAGMA_ONCE) |
|
21 |
+# pragma once |
|
22 |
+#endif |
|
23 |
+ |
|
24 |
+#include <boost/interprocess/detail/config_begin.hpp> |
|
25 |
+#include <boost/interprocess/detail/workaround.hpp> |
|
26 |
+ |
|
27 |
+#include <boost/interprocess/creation_tags.hpp> |
|
28 |
+#include <boost/interprocess/exceptions.hpp> |
|
29 |
+#include <boost/interprocess/detail/posix_time_types_wrk.hpp> |
|
30 |
+#include <boost/interprocess/sync/detail/locks.hpp> |
|
31 |
+#include <boost/interprocess/sync/detail/common_algorithms.hpp> |
|
32 |
+ |
|
33 |
+#if !defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) && \ |
|
34 |
+ defined(BOOST_INTERPROCESS_POSIX_PROCESS_SHARED) && \ |
|
35 |
+ defined(BOOST_INTERPROCESS_POSIX_UNNAMED_SEMAPHORES) |
|
36 |
+ #include <boost/interprocess/sync/posix/semaphore.hpp> |
|
37 |
+ #define BOOST_INTERPROCESS_SEMAPHORE_USE_POSIX |
|
38 |
+#elif !defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) && defined (BOOST_INTERPROCESS_WINDOWS) |
|
39 |
+ //Experimental... |
|
40 |
+ #include <boost/interprocess/sync/windows/semaphore.hpp> |
|
41 |
+ #define BOOST_INTERPROCESS_SEMAPHORE_USE_WINAPI |
|
42 |
+#else |
|
43 |
+ //spin_semaphore is used |
|
44 |
+ #include <boost/interprocess/sync/spin/semaphore.hpp> |
|
45 |
+#endif |
|
46 |
+ |
|
47 |
+#endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED |
|
48 |
+ |
|
49 |
+//!\file |
|
50 |
+//!Describes a interprocess_semaphore class for inter-process synchronization |
|
51 |
+ |
|
52 |
+namespace boost { |
|
53 |
+namespace interprocess { |
|
54 |
+ |
|
55 |
+//!Wraps a interprocess_semaphore that can be placed in shared memory and can be |
|
56 |
+//!shared between processes. Allows timed lock tries |
|
57 |
+class interprocess_semaphore |
|
58 |
+{ |
|
59 |
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) |
|
60 |
+ //Non-copyable |
|
61 |
+ interprocess_semaphore(const interprocess_semaphore &); |
|
62 |
+ interprocess_semaphore &operator=(const interprocess_semaphore &); |
|
63 |
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED |
|
64 |
+ public: |
|
65 |
+ //!Creates a interprocess_semaphore with the given initial count. |
|
66 |
+ //!interprocess_exception if there is an error.*/ |
|
67 |
+ interprocess_semaphore(unsigned int initialCount); |
|
68 |
+ |
|
69 |
+ //!Destroys the interprocess_semaphore. |
|
70 |
+ //!Does not throw |
|
71 |
+ ~interprocess_semaphore(); |
|
72 |
+ |
|
73 |
+ //!Increments the interprocess_semaphore count. If there are processes/threads blocked waiting |
|
74 |
+ //!for the interprocess_semaphore, then one of these processes will return successfully from |
|
75 |
+ //!its wait function. If there is an error an interprocess_exception exception is thrown. |
|
76 |
+ void post(); |
|
77 |
+ |
|
78 |
+ //!Decrements the interprocess_semaphore. If the interprocess_semaphore value is not greater than zero, |
|
79 |
+ //!then the calling process/thread blocks until it can decrement the counter. |
|
80 |
+ //!If there is an error an interprocess_exception exception is thrown. |
|
81 |
+ void wait(); |
|
82 |
+ |
|
83 |
+ //!Decrements the interprocess_semaphore if the interprocess_semaphore's value is greater than zero |
|
84 |
+ //!and returns true. If the value is not greater than zero returns false. |
|
85 |
+ //!If there is an error an interprocess_exception exception is thrown. |
|
86 |
+ bool try_wait(); |
|
87 |
+ |
|
88 |
+ //!Decrements the interprocess_semaphore if the interprocess_semaphore's value is greater |
|
89 |
+ //!than zero and returns true. Otherwise, waits for the interprocess_semaphore |
|
90 |
+ //!to the posted or the timeout expires. If the timeout expires, the |
|
91 |
+ //!function returns false. If the interprocess_semaphore is posted the function |
|
92 |
+ //!returns true. If there is an error throws sem_exception |
|
93 |
+ bool timed_wait(const boost::posix_time::ptime &abs_time); |
|
94 |
+ |
|
95 |
+ //!Returns the interprocess_semaphore count |
|
96 |
+// int get_count() const; |
|
97 |
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) |
|
98 |
+ private: |
|
99 |
+ #if defined(BOOST_INTERPROCESS_SEMAPHORE_USE_POSIX) |
|
100 |
+ typedef ipcdetail::posix_semaphore internal_sem_t; |
|
101 |
+ #elif defined(BOOST_INTERPROCESS_SEMAPHORE_USE_WINAPI) |
|
102 |
+ typedef ipcdetail::winapi_semaphore internal_sem_t; |
|
103 |
+ #else |
|
104 |
+ typedef ipcdetail::spin_semaphore internal_sem_t; |
|
105 |
+ #endif //#if defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) |
|
106 |
+ internal_sem_t m_sem; |
|
107 |
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED |
|
108 |
+}; |
|
109 |
+ |
|
110 |
+} //namespace interprocess { |
|
111 |
+} //namespace boost { |
|
112 |
+ |
|
113 |
+namespace boost { |
|
114 |
+namespace interprocess { |
|
115 |
+ |
|
116 |
+inline interprocess_semaphore::interprocess_semaphore(unsigned int initialCount) |
|
117 |
+ : m_sem(initialCount) |
|
118 |
+{} |
|
119 |
+ |
|
120 |
+inline interprocess_semaphore::~interprocess_semaphore(){} |
|
121 |
+ |
|
122 |
+inline void interprocess_semaphore::wait() |
|
123 |
+{ |
|
124 |
+ ipcdetail::lock_to_wait<internal_sem_t> ltw(m_sem); |
|
125 |
+ timeout_when_locking_aware_lock(ltw); |
|
126 |
+} |
|
127 |
+ |
|
128 |
+inline bool interprocess_semaphore::try_wait() |
|
129 |
+{ return m_sem.try_wait(); } |
|
130 |
+ |
|
131 |
+inline bool interprocess_semaphore::timed_wait(const boost::posix_time::ptime &abs_time) |
|
132 |
+{ return m_sem.timed_wait(abs_time); } |
|
133 |
+ |
|
134 |
+inline void interprocess_semaphore::post() |
|
135 |
+{ m_sem.post(); } |
|
136 |
+ |
|
137 |
+} //namespace interprocess { |
|
138 |
+} //namespace boost { |
|
139 |
+ |
|
140 |
+#include <boost/interprocess/detail/config_end.hpp> |
|
141 |
+ |
|
142 |
+#endif //BOOST_INTERPROCESS_SEMAPHORE_HPP |
1 | 1 |
deleted file mode 100755 |
... | ... |
@@ -1,142 +0,0 @@ |
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_SEMAPHORE_HPP |
|
12 |
-#define BOOST_INTERPROCESS_SEMAPHORE_HPP |
|
13 |
- |
|
14 |
-#if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) |
|
15 |
- |
|
16 |
-#ifndef BOOST_CONFIG_HPP |
|
17 |
-# include <boost/config.hpp> |
|
18 |
-#endif |
|
19 |
-# |
|
20 |
-#if defined(BOOST_HAS_PRAGMA_ONCE) |
|
21 |
-# pragma once |
|
22 |
-#endif |
|
23 |
- |
|
24 |
-#include <boost/interprocess/detail/config_begin.hpp> |
|
25 |
-#include <boost/interprocess/detail/workaround.hpp> |
|
26 |
- |
|
27 |
-#include <boost/interprocess/creation_tags.hpp> |
|
28 |
-#include <boost/interprocess/exceptions.hpp> |
|
29 |
-#include <boost/interprocess/detail/posix_time_types_wrk.hpp> |
|
30 |
-#include <boost/interprocess/sync/detail/locks.hpp> |
|
31 |
-#include <boost/interprocess/sync/detail/common_algorithms.hpp> |
|
32 |
- |
|
33 |
-#if !defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) && \ |
|
34 |
- defined(BOOST_INTERPROCESS_POSIX_PROCESS_SHARED) && \ |
|
35 |
- defined(BOOST_INTERPROCESS_POSIX_UNNAMED_SEMAPHORES) |
|
36 |
- #include <boost/interprocess/sync/posix/semaphore.hpp> |
|
37 |
- #define BOOST_INTERPROCESS_SEMAPHORE_USE_POSIX |
|
38 |
-#elif !defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) && defined (BOOST_INTERPROCESS_WINDOWS) |
|
39 |
- //Experimental... |
|
40 |
- #include <boost/interprocess/sync/windows/semaphore.hpp> |
|
41 |
- #define BOOST_INTERPROCESS_SEMAPHORE_USE_WINAPI |
|
42 |
-#else |
|
43 |
- //spin_semaphore is used |
|
44 |
- #include <boost/interprocess/sync/spin/semaphore.hpp> |
|
45 |
-#endif |
|
46 |
- |
|
47 |
-#endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED |
|
48 |
- |
|
49 |
-//!\file |
|
50 |
-//!Describes a interprocess_semaphore class for inter-process synchronization |
|
51 |
- |
|
52 |
-namespace boost { |
|
53 |
-namespace interprocess { |
|
54 |
- |
|
55 |
-//!Wraps a interprocess_semaphore that can be placed in shared memory and can be |
|
56 |
-//!shared between processes. Allows timed lock tries |
|
57 |
-class interprocess_semaphore |
|
58 |
-{ |
|
59 |
- #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) |
|
60 |
- //Non-copyable |
|
61 |
- interprocess_semaphore(const interprocess_semaphore &); |
|
62 |
- interprocess_semaphore &operator=(const interprocess_semaphore &); |
|
63 |
- #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED |
|
64 |
- public: |
|
65 |
- //!Creates a interprocess_semaphore with the given initial count. |
|
66 |
- //!interprocess_exception if there is an error.*/ |
|
67 |
- interprocess_semaphore(unsigned int initialCount); |
|
68 |
- |
|
69 |
- //!Destroys the interprocess_semaphore. |
|
70 |
- //!Does not throw |
|
71 |
- ~interprocess_semaphore(); |
|
72 |
- |
|
73 |
- //!Increments the interprocess_semaphore count. If there are processes/threads blocked waiting |
|
74 |
- //!for the interprocess_semaphore, then one of these processes will return successfully from |
|
75 |
- //!its wait function. If there is an error an interprocess_exception exception is thrown. |
|
76 |
- void post(); |
|
77 |
- |
|
78 |
- //!Decrements the interprocess_semaphore. If the interprocess_semaphore value is not greater than zero, |
|
79 |
- //!then the calling process/thread blocks until it can decrement the counter. |
|
80 |
- //!If there is an error an interprocess_exception exception is thrown. |
|
81 |
- void wait(); |
|
82 |
- |
|
83 |
- //!Decrements the interprocess_semaphore if the interprocess_semaphore's value is greater than zero |
|
84 |
- //!and returns true. If the value is not greater than zero returns false. |
|
85 |
- //!If there is an error an interprocess_exception exception is thrown. |
|
86 |
- bool try_wait(); |
|
87 |
- |
|
88 |
- //!Decrements the interprocess_semaphore if the interprocess_semaphore's value is greater |
|
89 |
- //!than zero and returns true. Otherwise, waits for the interprocess_semaphore |
|
90 |
- //!to the posted or the timeout expires. If the timeout expires, the |
|
91 |
- //!function returns false. If the interprocess_semaphore is posted the function |
|
92 |
- //!returns true. If there is an error throws sem_exception |
|
93 |
- bool timed_wait(const boost::posix_time::ptime &abs_time); |
|
94 |
- |
|
95 |
- //!Returns the interprocess_semaphore count |
|
96 |
-// int get_count() const; |
|
97 |
- #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) |
|
98 |
- private: |
|
99 |
- #if defined(BOOST_INTERPROCESS_SEMAPHORE_USE_POSIX) |
|
100 |
- typedef ipcdetail::posix_semaphore internal_sem_t; |
|
101 |
- #elif defined(BOOST_INTERPROCESS_SEMAPHORE_USE_WINAPI) |
|
102 |
- typedef ipcdetail::winapi_semaphore internal_sem_t; |
|
103 |
- #else |
|
104 |
- typedef ipcdetail::spin_semaphore internal_sem_t; |
|
105 |
- #endif //#if defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) |
|
106 |
- internal_sem_t m_sem; |
|
107 |
- #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED |
|
108 |
-}; |
|
109 |
- |
|
110 |
-} //namespace interprocess { |
|
111 |
-} //namespace boost { |
|
112 |
- |
|
113 |
-namespace boost { |
|
114 |
-namespace interprocess { |
|
115 |
- |
|
116 |
-inline interprocess_semaphore::interprocess_semaphore(unsigned int initialCount) |
|
117 |
- : m_sem(initialCount) |
|
118 |
-{} |
|
119 |
- |
|
120 |
-inline interprocess_semaphore::~interprocess_semaphore(){} |
|
121 |
- |
|
122 |
-inline void interprocess_semaphore::wait() |
|
123 |
-{ |
|
124 |
- ipcdetail::lock_to_wait<internal_sem_t> ltw(m_sem); |
|
125 |
- timeout_when_locking_aware_lock(ltw); |
|
126 |
-} |
|
127 |
- |
|
128 |
-inline bool interprocess_semaphore::try_wait() |
|
129 |
-{ return m_sem.try_wait(); } |
|
130 |
- |
|
131 |
-inline bool interprocess_semaphore::timed_wait(const boost::posix_time::ptime &abs_time) |
|
132 |
-{ return m_sem.timed_wait(abs_time); } |
|
133 |
- |
|
134 |
-inline void interprocess_semaphore::post() |
|
135 |
-{ m_sem.post(); } |
|
136 |
- |
|
137 |
-} //namespace interprocess { |
|
138 |
-} //namespace boost { |
|
139 |
- |
|
140 |
-#include <boost/interprocess/detail/config_end.hpp> |
|
141 |
- |
|
142 |
-#endif //BOOST_INTERPROCESS_SEMAPHORE_HPP |
1 | 1 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,142 @@ |
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_SEMAPHORE_HPP |
|
12 |
+#define BOOST_INTERPROCESS_SEMAPHORE_HPP |
|
13 |
+ |
|
14 |
+#if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) |
|
15 |
+ |
|
16 |
+#ifndef BOOST_CONFIG_HPP |
|
17 |
+# include <boost/config.hpp> |
|
18 |
+#endif |
|
19 |
+# |
|
20 |
+#if defined(BOOST_HAS_PRAGMA_ONCE) |
|
21 |
+# pragma once |
|
22 |
+#endif |
|
23 |
+ |
|
24 |
+#include <boost/interprocess/detail/config_begin.hpp> |
|
25 |
+#include <boost/interprocess/detail/workaround.hpp> |
|
26 |
+ |
|
27 |
+#include <boost/interprocess/creation_tags.hpp> |
|
28 |
+#include <boost/interprocess/exceptions.hpp> |
|
29 |
+#include <boost/interprocess/detail/posix_time_types_wrk.hpp> |
|
30 |
+#include <boost/interprocess/sync/detail/locks.hpp> |
|
31 |
+#include <boost/interprocess/sync/detail/common_algorithms.hpp> |
|
32 |
+ |
|
33 |
+#if !defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) && \ |
|
34 |
+ defined(BOOST_INTERPROCESS_POSIX_PROCESS_SHARED) && \ |
|
35 |
+ defined(BOOST_INTERPROCESS_POSIX_UNNAMED_SEMAPHORES) |
|
36 |
+ #include <boost/interprocess/sync/posix/semaphore.hpp> |
|
37 |
+ #define BOOST_INTERPROCESS_SEMAPHORE_USE_POSIX |
|
38 |
+#elif !defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) && defined (BOOST_INTERPROCESS_WINDOWS) |
|
39 |
+ //Experimental... |
|
40 |
+ #include <boost/interprocess/sync/windows/semaphore.hpp> |
|
41 |
+ #define BOOST_INTERPROCESS_SEMAPHORE_USE_WINAPI |
|
42 |
+#else |
|
43 |
+ //spin_semaphore is used |
|
44 |
+ #include <boost/interprocess/sync/spin/semaphore.hpp> |
|
45 |
+#endif |
|
46 |
+ |
|
47 |
+#endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED |
|
48 |
+ |
|
49 |
+//!\file |
|
50 |
+//!Describes a interprocess_semaphore class for inter-process synchronization |
|
51 |
+ |
|
52 |
+namespace boost { |
|
53 |
+namespace interprocess { |
|
54 |
+ |
|
55 |
+//!Wraps a interprocess_semaphore that can be placed in shared memory and can be |
|
56 |
+//!shared between processes. Allows timed lock tries |
|
57 |
+class interprocess_semaphore |
|
58 |
+{ |
|
59 |
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) |
|
60 |
+ //Non-copyable |
|
61 |
+ interprocess_semaphore(const interprocess_semaphore &); |
|
62 |
+ interprocess_semaphore &operator=(const interprocess_semaphore &); |
|
63 |
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED |
|
64 |
+ public: |
|
65 |
+ //!Creates a interprocess_semaphore with the given initial count. |
|
66 |
+ //!interprocess_exception if there is an error.*/ |
|
67 |
+ interprocess_semaphore(unsigned int initialCount); |
|
68 |
+ |
|
69 |
+ //!Destroys the interprocess_semaphore. |
|
70 |
+ //!Does not throw |
|
71 |
+ ~interprocess_semaphore(); |
|
72 |
+ |
|
73 |
+ //!Increments the interprocess_semaphore count. If there are processes/threads blocked waiting |
|
74 |
+ //!for the interprocess_semaphore, then one of these processes will return successfully from |
|
75 |
+ //!its wait function. If there is an error an interprocess_exception exception is thrown. |
|
76 |
+ void post(); |
|
77 |
+ |
|
78 |
+ //!Decrements the interprocess_semaphore. If the interprocess_semaphore value is not greater than zero, |
|
79 |
+ //!then the calling process/thread blocks until it can decrement the counter. |
|
80 |
+ //!If there is an error an interprocess_exception exception is thrown. |
|
81 |
+ void wait(); |
|
82 |
+ |
|
83 |
+ //!Decrements the interprocess_semaphore if the interprocess_semaphore's value is greater than zero |
|
84 |
+ //!and returns true. If the value is not greater than zero returns false. |
|
85 |
+ //!If there is an error an interprocess_exception exception is thrown. |
|
86 |
+ bool try_wait(); |
|
87 |
+ |
|
88 |
+ //!Decrements the interprocess_semaphore if the interprocess_semaphore's value is greater |
|
89 |
+ //!than zero and returns true. Otherwise, waits for the interprocess_semaphore |
|
90 |
+ //!to the posted or the timeout expires. If the timeout expires, the |
|
91 |
+ //!function returns false. If the interprocess_semaphore is posted the function |
|
92 |
+ //!returns true. If there is an error throws sem_exception |
|
93 |
+ bool timed_wait(const boost::posix_time::ptime &abs_time); |
|
94 |
+ |
|
95 |
+ //!Returns the interprocess_semaphore count |
|
96 |
+// int get_count() const; |
|
97 |
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) |
|
98 |
+ private: |
|
99 |
+ #if defined(BOOST_INTERPROCESS_SEMAPHORE_USE_POSIX) |
|
100 |
+ typedef ipcdetail::posix_semaphore internal_sem_t; |
|
101 |
+ #elif defined(BOOST_INTERPROCESS_SEMAPHORE_USE_WINAPI) |
|
102 |
+ typedef ipcdetail::winapi_semaphore internal_sem_t; |
|
103 |
+ #else |
|
104 |
+ typedef ipcdetail::spin_semaphore internal_sem_t; |
|
105 |
+ #endif //#if defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) |
|
106 |
+ internal_sem_t m_sem; |
|
107 |
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED |
|
108 |
+}; |
|
109 |
+ |
|
110 |
+} //namespace interprocess { |
|
111 |
+} //namespace boost { |
|
112 |
+ |
|
113 |
+namespace boost { |
|
114 |
+namespace interprocess { |
|
115 |
+ |
|
116 |
+inline interprocess_semaphore::interprocess_semaphore(unsigned int initialCount) |
|
117 |
+ : m_sem(initialCount) |
|
118 |
+{} |
|
119 |
+ |
|
120 |
+inline interprocess_semaphore::~interprocess_semaphore(){} |
|
121 |
+ |
|
122 |
+inline void interprocess_semaphore::wait() |
|
123 |
+{ |
|
124 |
+ ipcdetail::lock_to_wait<internal_sem_t> ltw(m_sem); |
|
125 |
+ timeout_when_locking_aware_lock(ltw); |
|
126 |
+} |
|
127 |
+ |
|
128 |
+inline bool interprocess_semaphore::try_wait() |
|
129 |
+{ return m_sem.try_wait(); } |
|
130 |
+ |
|
131 |
+inline bool interprocess_semaphore::timed_wait(const boost::posix_time::ptime &abs_time) |
|
132 |
+{ return m_sem.timed_wait(abs_time); } |
|
133 |
+ |
|
134 |
+inline void interprocess_semaphore::post() |
|
135 |
+{ m_sem.post(); } |
|
136 |
+ |
|
137 |
+} //namespace interprocess { |
|
138 |
+} //namespace boost { |
|
139 |
+ |
|
140 |
+#include <boost/interprocess/detail/config_end.hpp> |
|
141 |
+ |
|
142 |
+#endif //BOOST_INTERPROCESS_SEMAPHORE_HPP |