File indexing completed on 2025-01-18 09:39:21
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef BOOST_LOG_DETAIL_EVENT_HPP_INCLUDED_
0014 #define BOOST_LOG_DETAIL_EVENT_HPP_INCLUDED_
0015
0016 #include <boost/log/detail/config.hpp>
0017
0018 #ifdef BOOST_HAS_PRAGMA_ONCE
0019 #pragma once
0020 #endif
0021
0022 #ifndef BOOST_LOG_NO_THREADS
0023
0024 #include <boost/atomic/capabilities.hpp>
0025
0026 #if BOOST_ATOMIC_HAS_NATIVE_INT32_WAIT_NOTIFY == 2
0027 #include <boost/cstdint.hpp>
0028 #include <boost/atomic/atomic.hpp>
0029 #define BOOST_LOG_EVENT_USE_ATOMIC
0030 #elif defined(BOOST_THREAD_PLATFORM_PTHREAD) && defined(_POSIX_SEMAPHORES) && _POSIX_SEMAPHORES > 0 && BOOST_ATOMIC_FLAG_LOCK_FREE == 2
0031 #include <semaphore.h>
0032 #include <boost/cstdint.hpp>
0033 #include <boost/atomic/atomic_flag.hpp>
0034 #define BOOST_LOG_EVENT_USE_POSIX_SEMAPHORE
0035 #elif defined(BOOST_THREAD_PLATFORM_WIN32)
0036 #include <boost/cstdint.hpp>
0037 #include <boost/atomic/atomic.hpp>
0038 #define BOOST_LOG_EVENT_USE_WINAPI
0039 #else
0040 #include <boost/thread/mutex.hpp>
0041 #include <boost/thread/condition_variable.hpp>
0042 #define BOOST_LOG_EVENT_USE_BOOST_CONDITION_VARIABLE
0043 #endif
0044
0045 #include <boost/log/detail/header.hpp>
0046
0047 namespace boost {
0048
0049 BOOST_LOG_OPEN_NAMESPACE
0050
0051 namespace aux {
0052
0053 #if defined(BOOST_LOG_EVENT_USE_ATOMIC)
0054
0055 class atomic_based_event
0056 {
0057 private:
0058 boost::atomic< boost::uint32_t > m_state;
0059
0060 public:
0061
0062 atomic_based_event() : m_state(0u) {}
0063
0064
0065 BOOST_LOG_API void wait();
0066
0067 BOOST_LOG_API void set_signalled();
0068
0069
0070 BOOST_DELETED_FUNCTION(atomic_based_event(atomic_based_event const&))
0071 BOOST_DELETED_FUNCTION(atomic_based_event& operator= (atomic_based_event const&))
0072 };
0073
0074 typedef atomic_based_event event;
0075
0076 #elif defined(BOOST_LOG_EVENT_USE_POSIX_SEMAPHORE)
0077
0078 class sem_based_event
0079 {
0080 private:
0081 boost::atomic_flag m_state;
0082 sem_t m_semaphore;
0083
0084 public:
0085
0086 BOOST_LOG_API sem_based_event();
0087
0088 BOOST_LOG_API ~sem_based_event();
0089
0090
0091 BOOST_LOG_API void wait();
0092
0093 BOOST_LOG_API void set_signalled();
0094
0095
0096 BOOST_DELETED_FUNCTION(sem_based_event(sem_based_event const&))
0097 BOOST_DELETED_FUNCTION(sem_based_event& operator= (sem_based_event const&))
0098 };
0099
0100 typedef sem_based_event event;
0101
0102 #elif defined(BOOST_LOG_EVENT_USE_WINAPI)
0103
0104 class winapi_based_event
0105 {
0106 private:
0107 boost::atomic< boost::uint32_t > m_state;
0108 void* m_event;
0109
0110 public:
0111
0112 BOOST_LOG_API winapi_based_event();
0113
0114 BOOST_LOG_API ~winapi_based_event();
0115
0116
0117 BOOST_LOG_API void wait();
0118
0119 BOOST_LOG_API void set_signalled();
0120
0121
0122 BOOST_DELETED_FUNCTION(winapi_based_event(winapi_based_event const&))
0123 BOOST_DELETED_FUNCTION(winapi_based_event& operator= (winapi_based_event const&))
0124 };
0125
0126 typedef winapi_based_event event;
0127
0128 #else
0129
0130 class generic_event
0131 {
0132 private:
0133 boost::mutex m_mutex;
0134 boost::condition_variable m_cond;
0135 bool m_state;
0136
0137 public:
0138
0139 BOOST_LOG_API generic_event();
0140
0141 BOOST_LOG_API ~generic_event();
0142
0143
0144 BOOST_LOG_API void wait();
0145
0146 BOOST_LOG_API void set_signalled();
0147
0148
0149 BOOST_DELETED_FUNCTION(generic_event(generic_event const&))
0150 BOOST_DELETED_FUNCTION(generic_event& operator= (generic_event const&))
0151 };
0152
0153 typedef generic_event event;
0154
0155 #endif
0156
0157 }
0158
0159 BOOST_LOG_CLOSE_NAMESPACE
0160
0161 }
0162
0163 #include <boost/log/detail/footer.hpp>
0164
0165 #endif
0166
0167 #endif