forked from lewissbaker/cppcoro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto_reset_event.hpp
More file actions
44 lines (33 loc) · 831 Bytes
/
Copy pathauto_reset_event.hpp
File metadata and controls
44 lines (33 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) Lewis Baker
// Licenced under MIT license. See LICENSE.txt for details.
///////////////////////////////////////////////////////////////////////////////
#ifndef CPPCORO_AUTO_RESET_EVENT_HPP_INCLUDED
#define CPPCORO_AUTO_RESET_EVENT_HPP_INCLUDED
#include <cppcoro/config.hpp>
#if CPPCORO_OS_WINNT
# include <cppcoro/detail/win32.hpp>
#else
# include <mutex>
# include <condition_variable>
#endif
namespace cppcoro
{
class auto_reset_event
{
public:
auto_reset_event(bool initiallySet = false);
~auto_reset_event();
void set();
void wait();
private:
#if CPPCORO_OS_WINNT
cppcoro::detail::win32::safe_handle m_event;
#else
std::mutex m_mutex;
std::condition_variable m_cv;
bool m_isSet;
#endif
};
}
#endif