mirror of https://github.com/ARMmbed/mbed-os.git
BLE: Add Duration::forever() function.
parent
7b0cb27427
commit
07c05917e0
|
@ -49,8 +49,18 @@ struct DefaultRange<uint32_t> {
|
||||||
typedef Range<0, 0xFFFFFFFF> type;
|
typedef Range<0, 0xFFFFFFFF> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<uint32_t V>
|
||||||
|
struct Forever {
|
||||||
|
static const uint32_t VALUE = V;
|
||||||
|
};
|
||||||
|
|
||||||
template<typename Rep, uint32_t TB, typename Range = typename DefaultRange<Rep>::type >
|
|
||||||
|
template<
|
||||||
|
typename Rep,
|
||||||
|
uint32_t TB,
|
||||||
|
typename Range = typename DefaultRange<Rep>::type,
|
||||||
|
typename Forever = void*
|
||||||
|
>
|
||||||
struct Duration {
|
struct Duration {
|
||||||
Duration() : duration() { }
|
Duration() : duration() { }
|
||||||
|
|
||||||
|
@ -93,6 +103,11 @@ struct Duration {
|
||||||
return &duration;
|
return &duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Duration forever()
|
||||||
|
{
|
||||||
|
return Duration(Forever::VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Rep clamp(Rep in) {
|
static Rep clamp(Rep in) {
|
||||||
if (in < MIN) {
|
if (in < MIN) {
|
||||||
|
@ -211,6 +226,12 @@ bool operator>(Duration<Rep, Us, Range> lhs, Duration<Rep, Us, Range> rhs) {
|
||||||
return rhs < lhs;
|
return rhs < lhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------------------- Static variable initialization -------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
template<uint32_t V>
|
||||||
|
const uint32_t Forever<V>::VALUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //BLE_COMMON_DURATION_H_
|
#endif //BLE_COMMON_DURATION_H_
|
||||||
|
|
Loading…
Reference in New Issue