]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/signals2/include/boost/signals2/detail/lwm_pthreads.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / signals2 / include / boost / signals2 / detail / lwm_pthreads.hpp
CommitLineData
7c673cae
FG
1//
2// boost/signals2/detail/lwm_pthreads.hpp
3//
4// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
5// Copyright (c) 2008 Frank Mori Hess
6//
7// Distributed under the Boost Software License, Version 1.0. (See
8// accompanying file LICENSE_1_0.txt or copy at
9// http://www.boost.org/LICENSE_1_0.txt)
10//
11
12#ifndef BOOST_SIGNALS2_LWM_PTHREADS_HPP
13#define BOOST_SIGNALS2_LWM_PTHREADS_HPP
14
15// MS compatible compilers support #pragma once
16
17#if defined(_MSC_VER)
18# pragma once
19#endif
20
21#include <boost/assert.hpp>
22#include <pthread.h>
23
24namespace boost
25{
26
27namespace signals2
28{
29
30class mutex
31{
32private:
33
34 pthread_mutex_t m_;
35
36 mutex(mutex const &);
37 mutex & operator=(mutex const &);
38
39public:
40
41 mutex()
42 {
43
44// HPUX 10.20 / DCE has a nonstandard pthread_mutex_init
45
46#if defined(__hpux) && defined(_DECTHREADS_)
47 BOOST_VERIFY(pthread_mutex_init(&m_, pthread_mutexattr_default) == 0);
48#else
49 BOOST_VERIFY(pthread_mutex_init(&m_, 0) == 0);
50#endif
51 }
52
53 ~mutex()
54 {
55 BOOST_VERIFY(pthread_mutex_destroy(&m_) == 0);
56 }
57
58 void lock()
59 {
60 BOOST_VERIFY(pthread_mutex_lock(&m_) == 0);
61 }
62
63 bool try_lock()
64 {
65 return pthread_mutex_trylock(&m_) == 0;
66 }
67
68 void unlock()
69 {
70 BOOST_VERIFY(pthread_mutex_unlock(&m_) == 0);
71 }
72};
73
74} // namespace signals2
75
76} // namespace boost
77
78#endif // #ifndef BOOST_SIGNALS2_LWM_PTHREADS_HPP