rippled
Loading...
Searching...
No Matches
aged_container_utility.h
1#ifndef BEAST_CONTAINER_AGED_CONTAINER_UTILITY_H_INCLUDED
2#define BEAST_CONTAINER_AGED_CONTAINER_UTILITY_H_INCLUDED
3
4#include <xrpl/beast/container/aged_container.h>
5
6#include <chrono>
7#include <type_traits>
8
9namespace beast {
10
12template <class AgedContainer, class Rep, class Period>
14 type
15 expire(AgedContainer& c, std::chrono::duration<Rep, Period> const& age)
16{
17 std::size_t n(0);
18 auto const expired(c.clock().now() - age);
19 for (auto iter(c.chronological.cbegin());
20 iter != c.chronological.cend() && iter.when() <= expired;)
21 {
22 iter = c.erase(iter);
23 ++n;
24 }
25 return n;
26}
27
28} // namespace beast
29
30#endif
std::enable_if< is_aged_container< AgedContainer >::value, std::size_t >::type expire(AgedContainer &c, std::chrono::duration< Rep, Period > const &age)
Expire aged container items past the specified age.