CTRE Phoenix 6 C++ 24.3.0
ManualEvent.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) Cross The Road Electronics.  All rights reserved.
3 * License information can be found in CTRE_LICENSE.txt
4 * For support and suggestions contact support@ctr-electronics.com or file
5 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases
6 */
7#pragma once
8
10#include <condition_variable>
11
12namespace ctre {
13namespace phoenix {
14namespace threading {
15 /**
16 * Manual Event object, useful for signaling
17 * other threads about an event.
18 */
20 private:
21 bool _signal;
22 mutable size_t _waitCnt = 0;
23 mutable std::mutex _m;
24 mutable std::condition_variable _cv;
25
26 public:
27 /**
28 * \param initialSignal object defaults to Signaled or Not Signaled (default is not signaled).
29 */
30 ManualEvent(bool initialSignal = false);
31
32 /**
33 * Wait for event to be signaled, or for timeout
34 * \returns true if event is signaled, false if timed out.
35 */
36 bool WaitForSignal(int timeoutMs) const;
37
38 /**
39 * Signal the event. Any threads waiting on WaitForSignal() will return true.
40 */
41 void Signal();
42 /**
43 * Clear the event. Any threads waiting on WaitForSignal() will time out.
44 */
45 void Clear();
46 /**
47 * Reset the event signal without signaling other threads.
48 */
49 void Reset();
50 };
51}
52}
53}
Manual Event object, useful for signaling other threads about an event.
Definition: ManualEvent.hpp:19
void Reset()
Reset the event signal without signaling other threads.
void Signal()
Signal the event.
ManualEvent(bool initialSignal=false)
bool WaitForSignal(int timeoutMs) const
Wait for event to be signaled, or for timeout.
#define CTREXPORT
Definition: export.h:14
Definition: string_util.hpp:15