summaryrefslogtreecommitdiff
path: root/src/lib/event_history.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-05-03 11:17:34 +0200
committerCarl Hetherington <cth@carlh.net>2021-05-03 20:18:04 +0200
commit689fa55d1529ad88449ca464e9107c4dcc54d1cb (patch)
treeedd1264941263f2fa25a98d61f98c87876c5b667 /src/lib/event_history.cc
parent0aabe4060ea4bad7c7caac633aef0737fccff8c2 (diff)
C++11 tidying.
Diffstat (limited to 'src/lib/event_history.cc')
-rw-r--r--src/lib/event_history.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lib/event_history.cc b/src/lib/event_history.cc
index efe80b243..fca88aaf1 100644
--- a/src/lib/event_history.cc
+++ b/src/lib/event_history.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2017-2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2017-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,24 +18,28 @@
*/
+
#include "event_history.h"
#include "util.h"
#include <boost/thread/mutex.hpp>
+
using boost::optional;
+
EventHistory::EventHistory (int size)
: _size (size)
{
}
+
optional<float>
EventHistory::rate () const
{
boost::mutex::scoped_lock lock (_mutex);
- if (int (_history.size()) < _size) {
- return optional<float>();
+ if (int(_history.size()) < _size) {
+ return {};
}
struct timeval now;
@@ -44,6 +48,7 @@ EventHistory::rate () const
return _size / (seconds (now) - seconds (_history.back ()));
}
+
void
EventHistory::event ()
{
@@ -52,7 +57,7 @@ EventHistory::event ()
struct timeval tv;
gettimeofday (&tv, 0);
_history.push_front (tv);
- if (int (_history.size()) > _size) {
+ if (int(_history.size()) > _size) {
_history.pop_back ();
}
}