Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
ttl_timer.h
1#ifndef TTL_TIMER_H
2#define TTL_TIMER_H
3
4#include <mutex>
5#include <condition_variable>
6#include <atomic>
7
8namespace ara
9{
10 namespace com
11 {
12 namespace helper
13 {
17 {
18 private:
19 std::mutex mMutex;
20 std::unique_lock<std::mutex> mLock;
21 std::condition_variable mConditionVariable;
22 bool mRequested;
23 bool mDisposing;
24 std::atomic_bool mSignalFlag;
25 uint32_t mTtl;
26
27 public:
28 TtlTimer() noexcept;
29 TtlTimer(const TtlTimer &) = delete;
30 TtlTimer &operator=(const TtlTimer &) = delete;
31 ~TtlTimer() noexcept;
32
36 bool GetRequested() const noexcept;
37
41 void SetRequested(bool requested) noexcept;
42
46 bool GetOffered() const noexcept;
47
52 void SetOffered(uint32_t ttl) noexcept;
53
57 void WaitForSignal();
58
61 bool WaitForExpiration();
62
65 void Dispose() noexcept;
66 };
67 }
68 }
69}
70
71#endif
Time To Live countdown timer.
Definition: ttl_timer.h:17
bool GetRequested() const noexcept
Indicate whether the service client is requested or not.
Definition: ttl_timer.cpp:17
void WaitForSignal()
Wait for a signal from SetRequested or SetOffered.
Definition: ttl_timer.cpp:41
bool GetOffered() const noexcept
Indicate whether the service server is offered or not.
Definition: ttl_timer.cpp:29
void SetOffered(uint32_t ttl) noexcept
Set the service offered status.
Definition: ttl_timer.cpp:34
bool WaitForExpiration()
Wait for the timer to expire or reset.
Definition: ttl_timer.cpp:57
void Dispose() noexcept
Dispose the timer which causes all the waitings return immediately.
Definition: ttl_timer.cpp:85
void SetRequested(bool requested) noexcept
Set the service requested status.
Definition: ttl_timer.cpp:22