File indexing completed on 2026-04-07 08:07:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_INTERPROCESS_POSIX_SEMAPHORE_HPP
0012 #define BOOST_INTERPROCESS_POSIX_SEMAPHORE_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
0026 #include <boost/interprocess/sync/posix/semaphore_wrapper.hpp>
0027
0028 namespace boost {
0029 namespace interprocess {
0030 namespace ipcdetail {
0031
0032 class posix_semaphore
0033 {
0034 posix_semaphore();
0035 posix_semaphore(const posix_semaphore&);
0036 posix_semaphore &operator= (const posix_semaphore &);
0037
0038 public:
0039 posix_semaphore(unsigned int initialCount)
0040 { semaphore_init(&m_sem, initialCount); }
0041
0042 ~posix_semaphore()
0043 { semaphore_destroy(&m_sem); }
0044
0045 void post()
0046 { semaphore_post(&m_sem); }
0047
0048 void wait()
0049 { semaphore_wait(&m_sem); }
0050
0051 bool try_wait()
0052 { return semaphore_try_wait(&m_sem); }
0053
0054 template<class TimePoint>
0055 bool timed_wait(const TimePoint &abs_time)
0056 { return semaphore_timed_wait(&m_sem, abs_time); }
0057
0058 private:
0059 sem_t m_sem;
0060 };
0061
0062 }
0063 }
0064 }
0065
0066 #include <boost/interprocess/detail/config_end.hpp>
0067
0068 #endif