Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-24 08:29:36

0001 //////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
0004 // Software License, Version 1.0. (See accompanying file
0005 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // See http://www.boost.org/libs/interprocess for documentation.
0008 //
0009 //////////////////////////////////////////////////////////////////////////////
0010 
0011 #ifndef BOOST_INTERPROCESS_POSIX_NAMED_MUTEX_HPP
0012 #define BOOST_INTERPROCESS_POSIX_NAMED_MUTEX_HPP
0013 
0014 #ifndef BOOST_CONFIG_HPP
0015 #  include <boost/config.hpp>
0016 #endif
0017 0018 ">#
0019 #if defined(BOOST_HAS_PRAGMA_ONCE)
0020 #  pragma once
0021 #endif
0022 
0023 #include <boost/interprocess/detail/config_begin.hpp>
0024 #include <boost/interprocess/detail/workaround.hpp>
0025 #include <boost/interprocess/creation_tags.hpp>
0026 #include <boost/interprocess/exceptions.hpp>
0027 #include <boost/interprocess/detail/interprocess_tester.hpp>
0028 #include <boost/interprocess/permissions.hpp>
0029 #include <boost/interprocess/timed_utils.hpp>
0030 #include <boost/interprocess/sync/posix/named_semaphore.hpp>
0031 
0032 namespace boost {
0033 namespace interprocess {
0034 namespace ipcdetail {
0035 
0036 class named_condition;
0037 
0038 class posix_named_mutex
0039 {
0040    #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0041 
0042    posix_named_mutex();
0043    posix_named_mutex(const posix_named_mutex &);
0044    posix_named_mutex &operator=(const posix_named_mutex &);
0045    friend class named_condition;
0046    #endif   //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0047 
0048    public:
0049    posix_named_mutex(create_only_t, const char *name, const permissions &perm = permissions());
0050 
0051    posix_named_mutex(open_or_create_t, const char *name, const permissions &perm = permissions());
0052 
0053    posix_named_mutex(open_only_t, const char *name);
0054 
0055    ~posix_named_mutex();
0056 
0057    void unlock();
0058    void lock();
0059    bool try_lock();
0060 
0061    template<class TimePoint>
0062    bool timed_lock(const TimePoint &abs_time);
0063 
0064    template<class TimePoint>
0065    bool try_lock_until(const TimePoint &abs_time)
0066    {  return this->timed_lock(abs_time);  }
0067 
0068    template<class Duration>
0069    bool try_lock_for(const Duration &dur)
0070    {  return this->timed_lock(duration_to_ustime(dur)); }
0071 
0072    static bool remove(const char *name);
0073 
0074    #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0075    private:
0076    friend class interprocess_tester;
0077    void dont_close_on_destruction();
0078 
0079    posix_named_semaphore m_sem;
0080    #endif   //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0081 };
0082 
0083 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0084 
0085 inline posix_named_mutex::posix_named_mutex(create_only_t, const char *name, const permissions &perm)
0086    :  m_sem(create_only, name, 1, perm)
0087 {}
0088 
0089 inline posix_named_mutex::posix_named_mutex(open_or_create_t, const char *name, const permissions &perm)
0090    :  m_sem(open_or_create, name, 1, perm)
0091 {}
0092 
0093 inline posix_named_mutex::posix_named_mutex(open_only_t, const char *name)
0094    :  m_sem(open_only, name)
0095 {}
0096 
0097 inline void posix_named_mutex::dont_close_on_destruction()
0098 {  interprocess_tester::dont_close_on_destruction(m_sem);  }
0099 
0100 inline posix_named_mutex::~posix_named_mutex()
0101 {}
0102 
0103 inline void posix_named_mutex::lock()
0104 {  m_sem.wait();  }
0105 
0106 inline void posix_named_mutex::unlock()
0107 {  m_sem.post();  }
0108 
0109 inline bool posix_named_mutex::try_lock()
0110 {  return m_sem.try_wait();  }
0111 
0112 template<class TimePoint>
0113 inline bool posix_named_mutex::timed_lock(const TimePoint &abs_time)
0114 {  return m_sem.timed_wait(abs_time);  }
0115 
0116 inline bool posix_named_mutex::remove(const char *name)
0117 {  return posix_named_semaphore::remove(name);   }
0118 
0119 #endif   //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0120 
0121 }  //namespace ipcdetail {
0122 }  //namespace interprocess {
0123 }  //namespace boost {
0124 
0125 #include <boost/interprocess/detail/config_end.hpp>
0126 
0127 #endif   //BOOST_INTERPROCESS_POSIX_NAMED_MUTEX_HPP