diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj
index 68cac2863e..0a749badf8 100644
--- a/Builds/VisualStudio2013/RippleD.vcxproj
+++ b/Builds/VisualStudio2013/RippleD.vcxproj
@@ -164,8 +164,6 @@
-
-
diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters
index 05fd2a805e..9f47c1f218 100644
--- a/Builds/VisualStudio2013/RippleD.vcxproj.filters
+++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters
@@ -630,9 +630,6 @@
beast\chrono
-
- beast\chrono
-
beast\chrono
diff --git a/src/beast/beast/chrono/abstract_clock.h b/src/beast/beast/chrono/abstract_clock.h
index d085825c5d..6f2c830388 100644
--- a/src/beast/beast/chrono/abstract_clock.h
+++ b/src/beast/beast/chrono/abstract_clock.h
@@ -27,12 +27,12 @@ namespace beast {
/** Abstract interface to a clock.
- The abstract clock interface allows a dependency injection to take
- place so that the choice of implementation can be made at run-time
- instead of compile time. The trade-off is that the Duration used to
- represent the clock must be chosen at compile time and cannot be
- changed. This includes both the choice of representation (integers
- for example) and the period in ticks corresponding to one second.
+ This makes now() a member function instead of a static member, so
+ an instance of the class can be dependency injected, facilitating
+ unit tests where time may be controlled.
+
+ An abstract_clock inherits all the nested types of the Clock
+ template parameter.
Example:
@@ -40,56 +40,37 @@ namespace beast {
struct Implementation
{
- abstract_clock & m_clock;
-
- // Dependency injection
- //
- explicit Implementation (
- abstract_clock & clock)
- : m_clock (clock)
+ using clock_type = abstract_clock ;
+ clock_type& clock_;
+ explicit Implementation (clock_type& clock)
+ : clock_(clock)
{
}
};
@endcode
- @tparam The length of time, in seconds, corresponding to one tick.
+ @tparam Clock A type meeting these requirements:
+ http://en.cppreference.com/w/cpp/concept/Clock
*/
-template
+template
class abstract_clock
{
public:
- typedef typename Duration::rep rep;
- typedef typename Duration::period period;
- typedef Duration duration;
- typedef std::chrono::time_point <
- abstract_clock, duration> time_point;
+ using rep = typename Clock::rep;
+ using period = typename Clock::period;
+ using duration = typename Clock::duration;
+ using time_point = typename Clock::time_point;
- virtual ~abstract_clock () { }
+ static bool const is_steady = Clock::is_steady;
- /** Returns `true` if this is a steady clock. */
- virtual bool is_steady () const = 0;
+ virtual ~abstract_clock() = default;
/** Returns the current time. */
- virtual time_point now () const = 0;
-
-#if 0
- /** Convert the specified time point to a string. */
- /** @{ */
- //virtual std::string to_string (time_point const& tp) const = 0;
-
- template
- std::string to_string (
- std::chrono::time_point const& tp) const
- {
- return to_string (
- std::chrono::time_point_cast (tp));
- }
- /** @} */
-#endif
+ virtual time_point now() const = 0;
/** Returning elapsed ticks since the epoch. */
- rep elapsed () const
+ rep elapsed()
{
return now().time_since_epoch().count();
}
@@ -99,68 +80,34 @@ public:
namespace detail {
-template
-struct basic_abstract_clock_wrapper : public abstract_clock
-{
- using typename abstract_clock ::duration;
- using typename abstract_clock ::time_point;
-
- bool is_steady () const
- {
- return TrivialClock::is_steady;
- }
-
- time_point now () const
- {
- return time_point (duration (
- std::chrono::duration_cast (
- TrivialClock::now().time_since_epoch ()).count ()));
- }
-};
-
-template
+template
struct abstract_clock_wrapper
- : public basic_abstract_clock_wrapper
+ : public abstract_clock
{
- // generic conversion displays the duration
- /*
- std::string to_string (typename basic_abstract_clock_wrapper <
- TrivialClock, Duration>::time_point const& tp) const
- {
- std::stringstream ss;
- ss << tp.time_since_epoch();
- return ss.str ();
- }
- */
-};
+ using typename abstract_clock::duration;
+ using typename abstract_clock::time_point;
-/*
-template
-struct abstract_clock_wrapper
- : public basic_abstract_clock_wrapper
-{
- typedef std::chrono::system_clock clock_type;
- std::string to_string (time_point const& tp)
+ time_point
+ now() const override
{
- std::stringstream ss;
- ss << clock_type::time_point (tp.time_since_epoch ());
- return ss.str ();
+ return Clock::now();
}
};
-*/
}
//------------------------------------------------------------------------------
-/** Retrieve a discrete clock for a type implementing the Clock concept.
- The interface is created as an object with static storage duration.
+/** Returns a global instance of an abstract clock.
+ @tparam Facade A type meeting these requirements:
+ http://en.cppreference.com/w/cpp/concept/Clock
+ @tparam Clock The actual concrete clock to use.
*/
-template
-abstract_clock & get_abstract_clock ()
+template
+abstract_clock&
+get_abstract_clock()
{
- static detail::abstract_clock_wrapper <
- TrivialClock, Duration> clock;
+ static detail::abstract_clock_wrapper clock;
return clock;
}
diff --git a/src/beast/beast/chrono/abstract_clock_io.h b/src/beast/beast/chrono/abstract_clock_io.h
deleted file mode 100644
index 45f9dd8154..0000000000
--- a/src/beast/beast/chrono/abstract_clock_io.h
+++ /dev/null
@@ -1,37 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of Beast: https://github.com/vinniefalco/Beast
- Copyright 2013, Vinnie Falco
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-#ifndef BEAST_CHRONO_ABSTRACT_CLOCK_IO_H_INCLUDED
-#define BEAST_CHRONO_ABSTRACT_CLOCK_IO_H_INCLUDED
-
-#include
-
-namespace beast {
-
-template
-std::basic_ostream &
-operator<< (std::basic_ostream & os,
- std::chrono::time_point , Duration> const& tp)
-{
- return os << tp.time_since_epoch() << " since epoch";
-}
-
-}
-
-#endif
diff --git a/src/beast/beast/chrono/basic_seconds_clock.h b/src/beast/beast/chrono/basic_seconds_clock.h
index 227e3de439..6247935b61 100644
--- a/src/beast/beast/chrono/basic_seconds_clock.h
+++ b/src/beast/beast/chrono/basic_seconds_clock.h
@@ -45,25 +45,25 @@ public:
class seconds_clock_thread
{
public:
- typedef std::mutex mutex;
- typedef std::condition_variable cond_var;
- typedef std::lock_guard lock_guard;
- typedef std::unique_lock unique_lock;
- typedef std::chrono::steady_clock clock_type;
- typedef std::chrono::seconds seconds;
- typedef std::thread thread;
- typedef std::vector workers;
+ using mutex = std::mutex;
+ using cond_var = std::condition_variable;
+ using lock_guard = std::lock_guard ;
+ using unique_lock = std::unique_lock ;
+ using clock_type = std::chrono::steady_clock;
+ using seconds = std::chrono::seconds;
+ using thread = std::thread;
+ using workers = std::vector ;
- bool m_stop;
- mutex m_mutex;
- cond_var m_cond;
- workers m_workers;
- thread m_thread;
+ bool stop_;
+ mutex mutex_;
+ cond_var cond_;
+ workers workers_;
+ thread thread_;
seconds_clock_thread ()
- : m_stop (false)
+ : stop_ (false)
{
- m_thread = thread (std::bind(
+ thread_ = thread (std::bind(
&seconds_clock_thread::run, this));
}
@@ -74,37 +74,37 @@ public:
void add (seconds_clock_worker& w)
{
- lock_guard lock (m_mutex);
- m_workers.push_back (&w);
+ lock_guard lock (mutex_);
+ workers_.push_back (&w);
}
void remove (seconds_clock_worker& w)
{
- lock_guard lock (m_mutex);
- m_workers.erase (std::find (
- m_workers.begin (), m_workers.end(), &w));
+ lock_guard lock (mutex_);
+ workers_.erase (std::find (
+ workers_.begin (), workers_.end(), &w));
}
void stop()
{
- if (m_thread.joinable())
+ if (thread_.joinable())
{
{
- lock_guard lock (m_mutex);
- m_stop = true;
+ lock_guard lock (mutex_);
+ stop_ = true;
}
- m_cond.notify_all();
- m_thread.join();
+ cond_.notify_all();
+ thread_.join();
}
}
void run()
{
- unique_lock lock (m_mutex);;
+ unique_lock lock (mutex_);;
for (;;)
{
- for (auto iter : m_workers)
+ for (auto iter : workers_)
iter->sample();
clock_type::time_point const when (
@@ -112,7 +112,7 @@ public:
clock_type::now().time_since_epoch()) +
seconds (1));
- if (m_cond.wait_until (lock, when, [this]{ return m_stop; }))
+ if (cond_.wait_until (lock, when, [this]{ return stop_; }))
return;
}
}
@@ -143,24 +143,26 @@ basic_seconds_clock_main_hook()
}
/** A clock whose minimum resolution is one second.
+
The purpose of this class is to optimize the performance of the now()
member function call. It uses a dedicated thread that wakes up at least
once per second to sample the requested trivial clock.
- @tparam TrivialClock The clock to sample.
+
+ @tparam Clock A type meeting these requirements:
+ http://en.cppreference.com/w/cpp/concept/Clock
*/
-template
+template
class basic_seconds_clock
{
public:
- typedef std::chrono::seconds resolution;
- typedef typename resolution::rep rep;
- typedef typename resolution::period period;
- typedef std::chrono::duration duration;
- typedef std::chrono::time_point time_point;
+ using rep = typename Clock::rep;
+ using period = typename Clock::period;
+ using duration = typename Clock::duration;
+ using time_point = typename Clock::time_point;
- static bool const is_steady = TrivialClock::is_steady;
+ static bool const is_steady = Clock::is_steady;
- static time_point now ()
+ static time_point now()
{
// Make sure the thread is constructed before the
// worker otherwise we will crash during destruction
@@ -176,45 +178,36 @@ public:
struct worker : detail::seconds_clock_worker
{
- typedef std::mutex mutex;
- typedef std::lock_guard lock_guard;
-
time_point m_now;
- mutex m_mutex;
+ std::mutex mutex_;
- static time_point get_now ()
+ worker()
+ : m_now(Clock::now())
{
- return time_point (floor (
- TrivialClock::now().time_since_epoch()));
+ detail::seconds_clock_thread::instance().add(*this);
}
- worker ()
- : m_now (get_now ())
+ ~worker()
{
- detail::seconds_clock_thread::instance().add (*this);
- }
-
- ~worker ()
- {
- detail::seconds_clock_thread::instance().remove (*this);
+ detail::seconds_clock_thread::instance().remove(*this);
}
time_point now()
{
- lock_guard lock (m_mutex);
+ std::lock_guard lock (mutex_);
return m_now;
}
- void sample ()
+ void sample()
{
- lock_guard lock (m_mutex);
- m_now = get_now ();
+ std::lock_guard lock (mutex_);
+ m_now = Clock::now();
}
};
static worker w;
- return w.now ();
+ return w.now();
}
};
diff --git a/src/beast/beast/chrono/chrono_io.h b/src/beast/beast/chrono/chrono_io.h
index a17cd4aea8..939be44e37 100644
--- a/src/beast/beast/chrono/chrono_io.h
+++ b/src/beast/beast/chrono/chrono_io.h
@@ -856,15 +856,15 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
tz = f.get_timezone();
}
time_t __t = system_clock::to_time_t(__tp);
- tm __tm;
+ tm* __tm;
if (tz == local)
{
- if (localtime_r(&__t, &__tm) == 0)
+ if (! (__tm = localtime(&__t)))
failed = true;
}
else
{
- if (gmtime_r(&__t, &__tm) == 0)
+ if (! (__tm = gmtime(&__t)))
failed = true;
}
if (!failed)
@@ -875,11 +875,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
_CharT pattern[] = {'%', 'F', 'T', '%', 'H', ':', '%', 'M', ':'};
pb = pattern;
pe = pb + sizeof(pattern) / sizeof(_CharT);
- failed = tp.put(__os, __os, __os.fill(), &__tm, pb, pe).failed();
+ failed = tp.put(__os, __os, __os.fill(), __tm, pb, pe).failed();
if (!failed)
{
duration __d = __tp - system_clock::from_time_t(__t) +
- seconds(__tm.tm_sec);
+ seconds(__tm->tm_sec);
if (__d.count() < 10)
__os << _CharT('0');
ios::fmtflags __flgs = __os.flags();
@@ -891,7 +891,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
_CharT sub_pattern[] = {' ', '%', 'z'};
pb = sub_pattern;
pe = pb + + sizeof(sub_pattern) / sizeof(_CharT);
- failed = tp.put(__os, __os, __os.fill(), &__tm, pb, pe).failed();
+ failed = tp.put(__os, __os, __os.fill(), __tm, pb, pe).failed();
}
else
{
@@ -901,7 +901,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
}
else
- failed = tp.put(__os, __os, __os.fill(), &__tm, pb, pe).failed();
+ failed = tp.put(__os, __os, __os.fill(), __tm, pb, pe).failed();
}
}
catch (...)
diff --git a/src/beast/beast/chrono/manual_clock.h b/src/beast/beast/chrono/manual_clock.h
index 24dd9ddd8f..0c31d5812e 100644
--- a/src/beast/beast/chrono/manual_clock.h
+++ b/src/beast/beast/chrono/manual_clock.h
@@ -25,68 +25,73 @@
namespace beast {
/** Manual clock implementation.
+
This concrete class implements the @ref abstract_clock interface and
allows the time to be advanced manually, mainly for the purpose of
providing a clock in unit tests.
- @tparam The length of time, in seconds, corresponding to one tick.
+
+ @tparam Clock A type meeting these requirements:
+ http://en.cppreference.com/w/cpp/concept/Clock
*/
-template
-class manual_clock : public abstract_clock
+template
+class manual_clock
+ : public abstract_clock
{
public:
- using typename abstract_clock ::rep;
- using typename abstract_clock ::duration;
- using typename abstract_clock ::time_point;
-
- explicit manual_clock (time_point const& t = time_point (Duration (0)))
- : m_now (t)
- {
- }
-
- bool is_steady () const
- {
- return IsSteady;
- }
-
- time_point now () const
- {
- return m_now;
- }
-
-#if 0
- std::string to_string (time_point const& tp) const
- {
- std::stringstream ss;
- ss << tp.time_since_epoch() << " from start";
- return ss.str ();
- }
-#endif
-
- /** Set the current time of the manual clock.
- Precondition:
- ! IsSteady || t > now()
- */
- void set (time_point const& t)
- {
- //if (IsSteady)
- m_now = t;
- }
-
- /** Convenience for setting the time using a duration in @ref rep units. */
- void set (rep v)
- {
- set (time_point (duration (v)));
- }
-
- /** Convenience for advancing the clock by one. */
- manual_clock& operator++ ()
- {
- m_now += duration (1);
- return *this;
- }
+ using typename abstract_clock::rep;
+ using typename abstract_clock::duration;
+ using typename abstract_clock::time_point;
private:
- time_point m_now;
+ time_point now_;
+
+public:
+ explicit
+ manual_clock (time_point const& now = time_point(duration(0)))
+ : now_(now)
+ {
+ }
+
+ time_point
+ now() const override
+ {
+ return now_;
+ }
+
+ /** Set the current time of the manual clock. */
+ void
+ set (time_point const& when)
+ {
+ assert(! Clock::is_steady || when >= now_);
+ now_ = when;
+ }
+
+ /** Convenience for setting the time in seconds from epoch. */
+ template
+ void
+ set(Integer seconds_from_epoch)
+ {
+ set(time_point(duration(
+ std::chrono::seconds(seconds_from_epoch))));
+ }
+
+ /** Advance the clock by a duration. */
+ template
+ void
+ advance(std::chrono::duration const& elapsed)
+ {
+ assert(! Clock::is_steady ||
+ (now_ + elapsed) >= now_);
+ now_ += elapsed;
+ }
+
+ /** Convenience for advancing the clock by one second. */
+ manual_clock&
+ operator++ ()
+ {
+ advance(std::chrono::seconds(1));
+ return *this;
+ }
};
}
diff --git a/src/beast/beast/chrono/tests/abstract_clock.test.cpp b/src/beast/beast/chrono/tests/abstract_clock.test.cpp
index 5bf4493ab9..1e5e3b0fc9 100644
--- a/src/beast/beast/chrono/tests/abstract_clock.test.cpp
+++ b/src/beast/beast/chrono/tests/abstract_clock.test.cpp
@@ -20,11 +20,8 @@
// MODULES: ../impl/chrono_io.cpp
#include
-#include
#include
-
#include
-
#include
#include
#include
@@ -34,7 +31,8 @@ namespace beast {
class abstract_clock_test : public unit_test::suite
{
public:
- void test (abstract_clock & c)
+ template
+ void test (abstract_clock& c)
{
{
auto const t1 (c.now ());
@@ -53,18 +51,18 @@ public:
void test_manual ()
{
- typedef manual_clock clock_type;
+ using clock_type = manual_clock;
clock_type c;
std::stringstream ss;
- ss << "now() = " << c.now () << std::endl;
+ ss << "now() = " << c.now().time_since_epoch() << std::endl;
- c.set (clock_type::time_point (std::chrono::seconds (1)));
- ss << "now() = " << c.now () << std::endl;
+ c.set (clock_type::time_point (std::chrono::seconds(1)));
+ ss << "now() = " << c.now().time_since_epoch() << std::endl;
- c.set (clock_type::time_point (std::chrono::seconds (2)));
- ss << "now() = " << c.now () << std::endl;
+ c.set (clock_type::time_point (std::chrono::seconds(2)));
+ ss << "now() = " << c.now().time_since_epoch() << std::endl;
log << ss.str();
}
@@ -72,16 +70,16 @@ public:
void run ()
{
log << "steady_clock";
- test (get_abstract_clock ());
+ test (get_abstract_clock<
+ std::chrono::steady_clock>());
log << "system_clock";
- test (get_abstract_clock ());
+ test (get_abstract_clock<
+ std::chrono::system_clock>());
log << "high_resolution_clock";
- test (get_abstract_clock ());
+ test (get_abstract_clock<
+ std::chrono::high_resolution_clock>());
log << "manual_clock";
test_manual ();
diff --git a/src/beast/beast/container/aged_map.h b/src/beast/beast/container/aged_map.h
index f9d0470fdc..680aad49de 100644
--- a/src/beast/beast/container/aged_map.h
+++ b/src/beast/beast/container/aged_map.h
@@ -31,12 +31,12 @@ namespace beast {
template <
class Key,
class T,
- class Duration = std::chrono::seconds,
+ class Clock = std::chrono::steady_clock,
class Compare = std::less ,
class Allocator = std::allocator >
>
using aged_map = detail::aged_ordered_container <
- false, true, Key, T, Duration, Compare, Allocator>;
+ false, true, Key, T, Clock, Compare, Allocator>;
}
diff --git a/src/beast/beast/container/aged_multimap.h b/src/beast/beast/container/aged_multimap.h
index c66ff227d8..55807388fd 100644
--- a/src/beast/beast/container/aged_multimap.h
+++ b/src/beast/beast/container/aged_multimap.h
@@ -31,12 +31,12 @@ namespace beast {
template <
class Key,
class T,
- class Duration = std::chrono::seconds,
+ class Clock = std::chrono::steady_clock,
class Compare = std::less ,
class Allocator = std::allocator >
>
using aged_multimap = detail::aged_ordered_container <
- true, true, Key, T, Duration, Compare, Allocator>;
+ true, true, Key, T, Clock, Compare, Allocator>;
}
diff --git a/src/beast/beast/container/aged_multiset.h b/src/beast/beast/container/aged_multiset.h
index 620270d2ec..aeb083fec2 100644
--- a/src/beast/beast/container/aged_multiset.h
+++ b/src/beast/beast/container/aged_multiset.h
@@ -30,12 +30,12 @@ namespace beast {
template <
class Key,
- class Duration = std::chrono::seconds,
+ class Clock = std::chrono::steady_clock,
class Compare = std::less ,
class Allocator = std::allocator
>
using aged_multiset = detail::aged_ordered_container <
- true, false, Key, void, Duration, Compare, Allocator>;
+ true, false, Key, void, Clock, Compare, Allocator>;
}
diff --git a/src/beast/beast/container/aged_set.h b/src/beast/beast/container/aged_set.h
index a5ef922d5c..076e4830a4 100644
--- a/src/beast/beast/container/aged_set.h
+++ b/src/beast/beast/container/aged_set.h
@@ -30,12 +30,12 @@ namespace beast {
template <
class Key,
- class Duration = std::chrono::seconds,
+ class Clock = std::chrono::steady_clock,
class Compare = std::less ,
class Allocator = std::allocator
>
using aged_set = detail::aged_ordered_container <
- false, false, Key, void, Duration, Compare, Allocator>;
+ false, false, Key, void, Clock, Compare, Allocator>;
}
diff --git a/src/beast/beast/container/aged_unordered_map.h b/src/beast/beast/container/aged_unordered_map.h
index b6031bc976..b632312660 100644
--- a/src/beast/beast/container/aged_unordered_map.h
+++ b/src/beast/beast/container/aged_unordered_map.h
@@ -31,13 +31,13 @@ namespace beast {
template <
class Key,
class T,
- class Duration = std::chrono::seconds,
+ class Clock = std::chrono::steady_clock,
class Hash = std::hash ,
class KeyEqual = std::equal_to ,
class Allocator = std::allocator >
>
using aged_unordered_map = detail::aged_unordered_container <
- false, true, Key, T, Duration, Hash, KeyEqual, Allocator>;
+ false, true, Key, T, Clock, Hash, KeyEqual, Allocator>;
}
diff --git a/src/beast/beast/container/aged_unordered_multimap.h b/src/beast/beast/container/aged_unordered_multimap.h
index 7512392923..c257700601 100644
--- a/src/beast/beast/container/aged_unordered_multimap.h
+++ b/src/beast/beast/container/aged_unordered_multimap.h
@@ -31,13 +31,13 @@ namespace beast {
template <
class Key,
class T,
- class Duration = std::chrono::seconds,
+ class Clock = std::chrono::steady_clock,
class Hash = std::hash ,
class KeyEqual = std::equal_to ,
class Allocator = std::allocator >
>
using aged_unordered_multimap = detail::aged_unordered_container <
- true, true, Key, T, Duration, Hash, KeyEqual, Allocator>;
+ true, true, Key, T, Clock, Hash, KeyEqual, Allocator>;
}
diff --git a/src/beast/beast/container/aged_unordered_multiset.h b/src/beast/beast/container/aged_unordered_multiset.h
index c1f3ef353a..7d033cacc3 100644
--- a/src/beast/beast/container/aged_unordered_multiset.h
+++ b/src/beast/beast/container/aged_unordered_multiset.h
@@ -30,13 +30,13 @@ namespace beast {
template <
class Key,
- class Duration = std::chrono::seconds,
+ class Clock = std::chrono::steady_clock,
class Hash = std::hash ,
class KeyEqual = std::equal_to ,
class Allocator = std::allocator
>
using aged_unordered_multiset = detail::aged_unordered_container <
- true, false, Key, void, Duration, Hash, KeyEqual, Allocator>;
+ true, false, Key, void, Clock, Hash, KeyEqual, Allocator>;
}
diff --git a/src/beast/beast/container/aged_unordered_set.h b/src/beast/beast/container/aged_unordered_set.h
index 83b37de041..cf98970bb9 100644
--- a/src/beast/beast/container/aged_unordered_set.h
+++ b/src/beast/beast/container/aged_unordered_set.h
@@ -30,13 +30,13 @@ namespace beast {
template <
class Key,
- class Duration = std::chrono::seconds,
+ class Clock = std::chrono::steady_clock,
class Hash = std::hash ,
class KeyEqual = std::equal_to ,
class Allocator = std::allocator
>
using aged_unordered_set = detail::aged_unordered_container <
- false, false, Key, void, Duration, Hash, KeyEqual, Allocator>;
+ false, false, Key, void, Clock, Hash, KeyEqual, Allocator>;
}
diff --git a/src/beast/beast/container/detail/aged_ordered_container.h b/src/beast/beast/container/detail/aged_ordered_container.h
index 38830aa375..4c8cc9f73d 100644
--- a/src/beast/beast/container/detail/aged_ordered_container.h
+++ b/src/beast/beast/container/detail/aged_ordered_container.h
@@ -22,15 +22,11 @@
#include
#include
-
#include
-
#include
#include
-
#include
#include
-
#include //
#include
#include
@@ -75,7 +71,7 @@ template <
bool IsMap,
class Key,
class T,
- class Duration = std::chrono::seconds,
+ class Clock = std::chrono::steady_clock,
class Compare = std::less ,
class Allocator = std::allocator <
typename std::conditional clock_type;
- typedef typename clock_type::time_point time_point;
- typedef typename clock_type::duration duration;
- typedef Key key_type;
- typedef T mapped_type;
- typedef typename std::conditional <
- IsMap,
- std::pair ,
- Key>::type value_type;
- typedef std::size_t size_type;
- typedef std::ptrdiff_t difference_type;
+ using clock_type = abstract_clock;
+ using time_point = typename clock_type::time_point;
+ using duration = typename clock_type::duration;
+ using key_type = Key;
+ using mapped_type = T;
+ using value_type = typename std::conditional <
+ IsMap, std::pair , Key>::type;
+ using size_type = std::size_t;
+ using difference_type = std::ptrdiff_t;
// Introspection (for unit tests)
- typedef std::false_type is_unordered;
- typedef std::integral_constant is_multi;
- typedef std::integral_constant is_map;
-
- // VFALCO TODO How can we reorder the declarations to keep
- // all the public things together contiguously?
+ using is_unordered = std::false_type;
+ using is_multi = std::integral_constant ;
+ using is_map = std::integral_constant ;
private:
static Key const& extract (value_type const& value)
@@ -1237,8 +1228,8 @@ private:
//------------------------------------------------------------------------------
template
-aged_ordered_container ::
+ class Clock, class Compare, class Allocator>
+aged_ordered_container ::
aged_ordered_container (
clock_type& clock)
: m_config (clock)
@@ -1246,8 +1237,8 @@ aged_ordered_container (
}
template
-aged_ordered_container ::
+ class Clock, class Compare, class Allocator>
+aged_ordered_container ::
aged_ordered_container (
clock_type& clock,
Compare const& comp)
@@ -1256,8 +1247,8 @@ aged_ordered_container (
}
template
-aged_ordered_container ::
+ class Clock, class Compare, class Allocator>
+aged_ordered_container ::
aged_ordered_container (
clock_type& clock,
Allocator const& alloc)
@@ -1266,8 +1257,8 @@ aged_ordered_container (
}
template
-aged_ordered_container ::
+ class Clock, class Compare, class Allocator>
+aged_ordered_container ::
aged_ordered_container (
clock_type& clock,
Compare const& comp,
@@ -1277,9 +1268,9 @@ aged_ordered_container (
}
template
+ class Clock, class Compare, class Allocator>
template
-aged_ordered_container ::
+aged_ordered_container ::
aged_ordered_container (InputIt first, InputIt last,
clock_type& clock)
: m_config (clock)
@@ -1288,9 +1279,9 @@ aged_ordered_container (InputIt first, InputIt last,
}
template
+ class Clock, class Compare, class Allocator>
template
-aged_ordered_container ::
+aged_ordered_container ::
aged_ordered_container (InputIt first, InputIt last,
clock_type& clock,
Compare const& comp)
@@ -1300,9 +1291,9 @@ aged_ordered_container (InputIt first, InputIt last,
}
template
+ class Clock, class Compare, class Allocator>
template
-aged_ordered_container ::
+aged_ordered_container ::
aged_ordered_container (InputIt first, InputIt last,
clock_type& clock,
Allocator const& alloc)
@@ -1312,9 +1303,9 @@ aged_ordered_container (InputIt first, InputIt last,
}
template
+ class Clock, class Compare, class Allocator>
template
-aged_ordered_container ::
+aged_ordered_container ::
aged_ordered_container (InputIt first, InputIt last,
clock_type& clock,
Compare const& comp,
@@ -1325,8 +1316,8 @@ aged_ordered_container (InputIt first, InputIt last,
}
template
-aged_ordered_container ::
+ class Clock, class Compare, class Allocator>
+aged_ordered_container ::
aged_ordered_container (aged_ordered_container const& other)
: m_config (other.m_config)
{
@@ -1334,8 +1325,8 @@ aged_ordered_container (aged_ordered_container const& other)
}
template
-aged_ordered_container ::
+ class Clock, class Compare, class Allocator>
+aged_ordered_container ::
aged_ordered_container (aged_ordered_container const& other,
Allocator const& alloc)
: m_config (other.m_config, alloc)
@@ -1344,8 +1335,8 @@ aged_ordered_container (aged_ordered_container const& other,
}
template
-aged_ordered_container ::
+ class Clock, class Compare, class Allocator>
+aged_ordered_container ::
aged_ordered_container (aged_ordered_container&& other)
: m_config (std::move (other.m_config))
, m_cont (std::move (other.m_cont))
@@ -1354,8 +1345,8 @@ aged_ordered_container (aged_ordered_container&& other)
}
template
-aged_ordered_container ::
+ class Clock, class Compare, class Allocator>
+aged_ordered_container ::
aged_ordered_container (aged_ordered_container&& other,
Allocator const& alloc)
: m_config (std::move (other.m_config), alloc)
@@ -1365,8 +1356,8 @@ aged_ordered_container (aged_ordered_container&& other,
}
template
-aged_ordered_container ::
+ class Clock, class Compare, class Allocator>
+aged_ordered_container ::
aged_ordered_container (std::initializer_list init,
clock_type& clock)
: m_config (clock)
@@ -1375,8 +1366,8 @@ aged_ordered_container (std::initializer_list init,
}
template
-aged_ordered_container ::
+ class Clock, class Compare, class Allocator>
+aged_ordered_container ::
aged_ordered_container (std::initializer_list init,
clock_type& clock,
Compare const& comp)
@@ -1386,8 +1377,8 @@ aged_ordered_container (std::initializer_list init,
}
template
-aged_ordered_container ::
+ class Clock, class Compare, class Allocator>
+aged_ordered_container ::
aged_ordered_container (std::initializer_list init,
clock_type& clock,
Allocator const& alloc)
@@ -1397,8 +1388,8 @@ aged_ordered_container (std::initializer_list init,
}
template
-aged_ordered_container ::
+ class Clock, class Compare, class Allocator>
+aged_ordered_container ::
aged_ordered_container (std::initializer_list init,
clock_type& clock,
Compare const& comp,
@@ -1409,17 +1400,17 @@ aged_ordered_container (std::initializer_list init,
}
template
-aged_ordered_container ::
+ class Clock, class Compare, class Allocator>
+aged_ordered_container ::
~aged_ordered_container()
{
clear();
}
template
+ class Clock, class Compare, class Allocator>
auto
-aged_ordered_container ::
+aged_ordered_container ::
operator= (aged_ordered_container const& other) ->
aged_ordered_container&
{
@@ -1433,9 +1424,9 @@ operator= (aged_ordered_container const& other) ->
}
template
+ class Clock, class Compare, class Allocator>
auto
-aged_ordered_container ::
+aged_ordered_container ::
operator= (aged_ordered_container&& other) ->
aged_ordered_container&
{
@@ -1447,9 +1438,9 @@ operator= (aged_ordered_container&& other) ->
}
template
+ class Clock, class Compare, class Allocator>
auto
-aged_ordered_container ::
+aged_ordered_container ::
operator= (std::initializer_list init) ->
aged_ordered_container&
{
@@ -1461,10 +1452,10 @@ operator= (std::initializer_list init) ->
//------------------------------------------------------------------------------
template
+ class Clock, class Compare, class Allocator>
template
typename std::conditional ::type&
-aged_ordered_container ::
+aged_ordered_container ::
at (K const& k)
{
auto const iter (m_cont.find (k,
@@ -1475,10 +1466,10 @@ at (K const& k)
}
template
+ class Clock, class Compare, class Allocator>
template
typename std::conditional ::type const&
-aged_ordered_container ::
+aged_ordered_container ::
at (K const& k) const
{
auto const iter (m_cont.find (k,
@@ -1489,10 +1480,10 @@ at (K const& k) const
}
template
+ class Clock, class Compare, class Allocator>
template
typename std::conditional ::type&
-aged_ordered_container ::
+aged_ordered_container ::
operator[] (Key const& key)
{
typename cont_type::insert_commit_data d;
@@ -1511,10 +1502,10 @@ operator[] (Key const& key)
}
template
+ class Clock, class Compare, class Allocator>
template
typename std::conditional ::type&
-aged_ordered_container ::
+aged_ordered_container ::
operator[] (Key&& key)
{
typename cont_type::insert_commit_data d;
@@ -1536,9 +1527,9 @@ operator[] (Key&& key)
//------------------------------------------------------------------------------
template
+ class Clock, class Compare, class Allocator>
void
-aged_ordered_container ::
+aged_ordered_container ::
clear()
{
for (auto iter (chronological.list.begin());
@@ -1550,10 +1541,10 @@ clear()
// map, set
template
+ class Clock, class Compare, class Allocator>
template
auto
-aged_ordered_container ::
+aged_ordered_container ::
insert (value_type const& value) ->
typename std::enable_if >::type
@@ -1573,10 +1564,10 @@ insert (value_type const& value) ->
// multimap, multiset
template
+ class Clock, class Compare, class Allocator>
template
auto
-aged_ordered_container ::
+aged_ordered_container ::
insert (value_type const& value) ->
typename std::enable_if ::type
@@ -1591,10 +1582,10 @@ insert (value_type const& value) ->
// set
template
+ class Clock, class Compare, class Allocator>
template
auto
-aged_ordered_container ::
+aged_ordered_container ::
insert (value_type&& value) ->
typename std::enable_if >::type
@@ -1614,10 +1605,10 @@ insert (value_type&& value) ->
// multiset
template
+ class Clock, class Compare, class Allocator>
template
auto
-aged_ordered_container ::
+aged_ordered_container ::
insert (value_type&& value) ->
typename std::enable_if ::type
@@ -1634,10 +1625,10 @@ insert (value_type&& value) ->
// map, set
template
+ class Clock, class Compare, class Allocator>
template
auto
-aged_ordered_container ::
+aged_ordered_container ::
insert (const_iterator hint, value_type const& value) ->
typename std::enable_if ::type
@@ -1657,10 +1648,10 @@ insert (const_iterator hint, value_type const& value) ->
// map, set
template
+ class Clock, class Compare, class Allocator>
template
auto
-aged_ordered_container ::
+aged_ordered_container ::
insert (const_iterator hint, value_type&& value) ->
typename std::enable_if ::type
@@ -1680,10 +1671,10 @@ insert (const_iterator hint, value_type&& value) ->
// map, set
template
+ class Clock, class Compare, class Allocator>
template
auto
-aged_ordered_container ::
+aged_ordered_container ::
emplace (Args&&... args) ->
typename std::enable_if >::type
@@ -1707,10 +1698,10 @@ emplace (Args&&... args) ->
// multiset, multimap
template
+ class Clock, class Compare, class Allocator>
template
auto
-aged_ordered_container ::
+aged_ordered_container ::
emplace (Args&&... args) ->
typename std::enable_if ::type
@@ -1726,10 +1717,10 @@ emplace (Args&&... args) ->
// map, set
template
+ class Clock, class Compare, class Allocator>
template
auto
-aged_ordered_container ::
+aged_ordered_container ::
emplace_hint (const_iterator hint, Args&&... args) ->
typename std::enable_if >::type
@@ -1752,10 +1743,10 @@ emplace_hint (const_iterator hint, Args&&... args) ->
}
template
+ class Clock, class Compare, class Allocator>
template