forked from awwit/httpserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvent.h
More file actions
33 lines (26 loc) · 635 Bytes
/
Event.h
File metadata and controls
33 lines (26 loc) · 635 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
#pragma once
#include <mutex>
#include <condition_variable>
#include <atomic>
namespace Utils
{
class Event
{
private:
std::mutex mtx;
std::condition_variable cv;
std::atomic<bool> signaled;
bool manually;
public:
Event(const bool signaled = false, const bool manualy = false) noexcept;
~Event() noexcept = default;
public:
void wait();
bool wait_for(const std::chrono::milliseconds &ms);
bool wait_until(const std::chrono::high_resolution_clock::time_point &tp);
void notify() noexcept;
void notify(const size_t threadsCount) noexcept;
void reset() noexcept;
bool notifed() const noexcept;
};
}