projects
/
dcpomatic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Various alignment tidying/fixups.
[dcpomatic.git]
/
src
/
lib
/
event_history.cc
diff --git
a/src/lib/event_history.cc
b/src/lib/event_history.cc
index efe80b243ce53f328609b1d8be2af1975a725b79..fca88aaf18a8b6a769d7a5fcb9cb9494d6ffa709 100644
(file)
--- a/
src/lib/event_history.cc
+++ b/
src/lib/event_history.cc
@@
-1,5
+1,5
@@
/*
/*
- Copyright (C) 2017-20
19
Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2017-20
21
Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
This file is part of DCP-o-matic.
@@
-18,24
+18,28
@@
*/
*/
+
#include "event_history.h"
#include "util.h"
#include <boost/thread/mutex.hpp>
#include "event_history.h"
#include "util.h"
#include <boost/thread/mutex.hpp>
+
using boost::optional;
using boost::optional;
+
EventHistory::EventHistory (int size)
: _size (size)
{
}
EventHistory::EventHistory (int size)
: _size (size)
{
}
+
optional<float>
EventHistory::rate () const
{
boost::mutex::scoped_lock lock (_mutex);
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;
}
struct timeval now;
@@
-44,6
+48,7
@@
EventHistory::rate () const
return _size / (seconds (now) - seconds (_history.back ()));
}
return _size / (seconds (now) - seconds (_history.back ()));
}
+
void
EventHistory::event ()
{
void
EventHistory::event ()
{
@@
-52,7
+57,7
@@
EventHistory::event ()
struct timeval tv;
gettimeofday (&tv, 0);
_history.push_front (tv);
struct timeval tv;
gettimeofday (&tv, 0);
_history.push_front (tv);
- if (int
(_history.size()) > _size) {
+ if (int(_history.size()) > _size) {
_history.pop_back ();
}
}
_history.pop_back ();
}
}