]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/interprocess/include/boost/interprocess/sync/posix/named_mutex.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / interprocess / include / boost / interprocess / sync / posix / named_mutex.hpp
CommitLineData
7c673cae
FG
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#ifndef BOOST_CONFIG_HPP
15# include <boost/config.hpp>
16#endif
17#
18#if defined(BOOST_HAS_PRAGMA_ONCE)
19# pragma once
20#endif
21
22#include <boost/interprocess/detail/config_begin.hpp>
23#include <boost/interprocess/detail/workaround.hpp>
24#include <boost/interprocess/creation_tags.hpp>
25#include <boost/interprocess/exceptions.hpp>
26#include <boost/interprocess/detail/interprocess_tester.hpp>
27#include <boost/interprocess/permissions.hpp>
28
29#include <boost/interprocess/sync/posix/named_semaphore.hpp>
30
31namespace boost {
32namespace interprocess {
33namespace ipcdetail {
34
35class named_condition;
36
37class posix_named_mutex
38{
39 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
40
41 posix_named_mutex();
42 posix_named_mutex(const posix_named_mutex &);
43 posix_named_mutex &operator=(const posix_named_mutex &);
44 friend class named_condition;
45 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
46
47 public:
48 posix_named_mutex(create_only_t create_only, const char *name, const permissions &perm = permissions());
49
50 posix_named_mutex(open_or_create_t open_or_create, const char *name, const permissions &perm = permissions());
51
52 posix_named_mutex(open_only_t open_only, const char *name);
53
54 ~posix_named_mutex();
55
56 void unlock();
57 void lock();
58 bool try_lock();
59 bool timed_lock(const boost::posix_time::ptime &abs_time);
60 static bool remove(const char *name);
61
62 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
63 private:
64 friend class interprocess_tester;
65 void dont_close_on_destruction();
66
67 posix_named_semaphore m_sem;
68 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
69};
70
71#if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
72
73inline posix_named_mutex::posix_named_mutex(create_only_t, const char *name, const permissions &perm)
74 : m_sem(create_only, name, 1, perm)
75{}
76
77inline posix_named_mutex::posix_named_mutex(open_or_create_t, const char *name, const permissions &perm)
78 : m_sem(open_or_create, name, 1, perm)
79{}
80
81inline posix_named_mutex::posix_named_mutex(open_only_t, const char *name)
82 : m_sem(open_only, name)
83{}
84
85inline void posix_named_mutex::dont_close_on_destruction()
86{ interprocess_tester::dont_close_on_destruction(m_sem); }
87
88inline posix_named_mutex::~posix_named_mutex()
89{}
90
91inline void posix_named_mutex::lock()
92{ m_sem.wait(); }
93
94inline void posix_named_mutex::unlock()
95{ m_sem.post(); }
96
97inline bool posix_named_mutex::try_lock()
98{ return m_sem.try_wait(); }
99
100inline bool posix_named_mutex::timed_lock(const boost::posix_time::ptime &abs_time)
101{ return m_sem.timed_wait(abs_time); }
102
103inline bool posix_named_mutex::remove(const char *name)
104{ return posix_named_semaphore::remove(name); }
105
106#endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
107
108} //namespace ipcdetail {
109} //namespace interprocess {
110} //namespace boost {
111
112#include <boost/interprocess/detail/config_end.hpp>
113
114#endif //BOOST_INTERPROCESS_POSIX_NAMED_MUTEX_HPP