From 07c05917e0baab4f16ac7294dae66adc0e5926cf Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Wed, 21 Nov 2018 10:22:21 +0000 Subject: [PATCH] BLE: Add Duration::forever() function. --- features/FEATURE_BLE/ble/common/Duration.h | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/features/FEATURE_BLE/ble/common/Duration.h b/features/FEATURE_BLE/ble/common/Duration.h index f37a03025e..a9082c894c 100644 --- a/features/FEATURE_BLE/ble/common/Duration.h +++ b/features/FEATURE_BLE/ble/common/Duration.h @@ -49,8 +49,18 @@ struct DefaultRange { typedef Range<0, 0xFFFFFFFF> type; }; +template +struct Forever { + static const uint32_t VALUE = V; +}; -template::type > + +template< + typename Rep, + uint32_t TB, + typename Range = typename DefaultRange::type, + typename Forever = void* +> struct Duration { Duration() : duration() { } @@ -93,6 +103,11 @@ struct Duration { return &duration; } + static Duration forever() + { + return Duration(Forever::VALUE); + } + private: static Rep clamp(Rep in) { if (in < MIN) { @@ -211,6 +226,12 @@ bool operator>(Duration lhs, Duration rhs) { return rhs < lhs; } +/* ---------------------- Static variable initialization -------------------- */ + + +template +const uint32_t Forever::VALUE; + } #endif //BLE_COMMON_DURATION_H_