Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent 6d9f8b8 commit 347626a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 1 addition & 3 deletions doomsday/libs/core/src/core/highperformancetimer.cpp
Expand Up @@ -25,11 +25,9 @@

namespace de {

namespace chr = std::chrono;

DE_PIMPL_NOREF(HighPerformanceTimer)
{
Time::TimePoint origin = chr::system_clock::now();
Time::TimePoint origin = std::chrono::system_clock::now();
ElapsedTimer timer;

Impl()
Expand Down
18 changes: 10 additions & 8 deletions doomsday/libs/core/src/core/timer.cpp
Expand Up @@ -25,12 +25,10 @@
#include <queue>
#include <atomic>

namespace sc = std::chrono;

namespace de {
namespace internal {

using TimePoint = sc::system_clock::time_point;
using TimePoint = std::chrono::system_clock::time_point;

/**
* Thread that posts timer events when it is time to trigger scheduled timers.
Expand All @@ -57,6 +55,8 @@ struct TimerScheduler : public Thread, public Lockable

void run() override
{
using namespace std::chrono;

while (running)
{
TimeSpan timeToWait = 0.0;
Expand All @@ -66,10 +66,10 @@ struct TimerScheduler : public Thread, public Lockable
DE_GUARD(this);
while (!pending.empty())
{
const auto now = sc::system_clock::now();
const auto now = system_clock::now();
const auto nextAt = pending.top().nextAt;

TimeSpan until = sc::duration_cast<sc::milliseconds>(nextAt - now).count() / 1.0e3;
TimeSpan until = duration_cast<milliseconds>(nextAt - now).count() / 1.0e3;
if (until <= 0.0)
{
// Time to trigger this timer.
Expand All @@ -83,10 +83,10 @@ struct TimerScheduler : public Thread, public Lockable
// Schedule the next trigger.
if (pt.repeatDuration > 0.0)
{
TimePoint nextAt = pt.nextAt + sc::microseconds(dint64(pt.repeatDuration * 1.0e6));
TimePoint nextAt = pt.nextAt + microseconds(dint64(pt.repeatDuration * 1.0e6));
#if defined (DE_DEBUG)
// Debugger may halt the process, don't bother retrying to post.
nextAt = de::max(nextAt, sc::system_clock::now());
nextAt = de::max(nextAt, system_clock::now());
#endif
pending.push(Pending{nextAt, pt.timer, pt.repeatDuration});
}
Expand All @@ -107,10 +107,12 @@ struct TimerScheduler : public Thread, public Lockable

void addPending(Timer &timer)
{
using namespace std::chrono;

DE_GUARD(this);
const TimeSpan repeatDuration = timer.interval();
pending.push(
Pending{sc::system_clock::now() + sc::microseconds(dint64(repeatDuration * 1.0e6)),
Pending{system_clock::now() + microseconds(dint64(repeatDuration * 1.0e6)),
&timer,
timer.isSingleShot() ? 0_ms : repeatDuration});
waiter.post();
Expand Down

0 comments on commit 347626a

Please sign in to comment.