Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:42

0001 //
0002 // detail/posix_static_mutex.hpp
0003 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_DETAIL_POSIX_STATIC_MUTEX_HPP
0012 #define BOOST_ASIO_DETAIL_POSIX_STATIC_MUTEX_HPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/config.hpp>
0019 
0020 #if defined(BOOST_ASIO_HAS_PTHREADS)
0021 
0022 #include <pthread.h>
0023 #include <boost/asio/detail/scoped_lock.hpp>
0024 
0025 #include <boost/asio/detail/push_options.hpp>
0026 
0027 namespace boost {
0028 namespace asio {
0029 namespace detail {
0030 
0031 struct posix_static_mutex
0032 {
0033   typedef boost::asio::detail::scoped_lock<posix_static_mutex> scoped_lock;
0034 
0035   // Initialise the mutex.
0036   void init()
0037   {
0038     // Nothing to do.
0039   }
0040 
0041   // Lock the mutex.
0042   void lock()
0043   {
0044     (void)::pthread_mutex_lock(&mutex_); // Ignore EINVAL.
0045   }
0046 
0047   // Unlock the mutex.
0048   void unlock()
0049   {
0050     (void)::pthread_mutex_unlock(&mutex_); // Ignore EINVAL.
0051   }
0052 
0053   ::pthread_mutex_t mutex_;
0054 };
0055 
0056 #define BOOST_ASIO_POSIX_STATIC_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER }
0057 
0058 } // namespace detail
0059 } // namespace asio
0060 } // namespace boost
0061 
0062 #include <boost/asio/detail/pop_options.hpp>
0063 
0064 #endif // defined(BOOST_ASIO_HAS_PTHREADS)
0065 
0066 #endif // BOOST_ASIO_DETAIL_POSIX_STATIC_MUTEX_HPP