File indexing completed on 2025-01-18 09:54:50
0001
0002
0003
0004
0005 #ifndef CPPCORO_DETAIL_LIGHTWEIGHT_MANUAL_RESET_EVENT_HPP_INCLUDED
0006 #define CPPCORO_DETAIL_LIGHTWEIGHT_MANUAL_RESET_EVENT_HPP_INCLUDED
0007
0008 #include <cppcoro/config.hpp>
0009
0010 #if CPPCORO_OS_LINUX || (CPPCORO_OS_WINNT >= 0x0602)
0011 # include <atomic>
0012 # include <cstdint>
0013 #elif CPPCORO_OS_WINNT
0014 # include <cppcoro/detail/win32.hpp>
0015 #else
0016 # include <mutex>
0017 # include <condition_variable>
0018 #endif
0019
0020 namespace cppcoro
0021 {
0022 namespace detail
0023 {
0024 class lightweight_manual_reset_event
0025 {
0026 public:
0027
0028 lightweight_manual_reset_event(bool initiallySet = false);
0029
0030 ~lightweight_manual_reset_event();
0031
0032 void set() noexcept;
0033
0034 void reset() noexcept;
0035
0036 void wait() noexcept;
0037
0038 private:
0039
0040 #if CPPCORO_OS_LINUX
0041 std::atomic<int> m_value;
0042 #elif CPPCORO_OS_WINNT >= 0x0602
0043
0044 std::atomic<std::uint8_t> m_value;
0045 #elif CPPCORO_OS_WINNT
0046
0047 cppcoro::detail::win32::handle_t m_eventHandle;
0048 #else
0049
0050
0051
0052
0053 std::mutex m_mutex;
0054 std::condition_variable m_cv;
0055 bool m_isSet;
0056 #endif
0057 };
0058 }
0059 }
0060
0061 #endif