Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
delay_timer.h
1#ifndef DELAY_TIMER_H
2#define DELAY_TIMER_H
3
4#include <thread>
5#include <condition_variable>
6
7namespace ara
8{
9 namespace diag
10 {
11 namespace routing
12 {
15 {
16 private:
17 const std::chrono::microseconds cSpinWait{1};
18
19 std::mutex mMutex;
20 std::unique_lock<std::mutex> mLock;
21 std::condition_variable mConditionVariable;
22 std::thread mThread;
23
24 void delay(std::chrono::seconds duration);
25
26 public:
27 DelayTimer() noexcept;
28 DelayTimer(const DelayTimer &) = delete;
29 DelayTimer &operator=(const DelayTimer &) = delete;
31
35 void Start(std::chrono::seconds delayDuration);
36
39 bool IsActive() const noexcept;
40
42 void Dispose();
43 };
44 }
45 }
46}
47
48#endif
A thread-safe countdown timer running on a different thread.
Definition: delay_timer.h:15
void Start(std::chrono::seconds delayDuration)
Start the timer if it has not been started yet.
Definition: delay_timer.cpp:20
bool IsActive() const noexcept
Indicate whether the timer is active or not.
Definition: delay_timer.cpp:33
void Dispose()
Release resources aquired by the timer.
Definition: delay_timer.cpp:38