Commit 0c13703d authored by Max Kellermann's avatar Max Kellermann

system/clock: convert to C++

parent b97b7a74
......@@ -278,7 +278,7 @@ libsystem_a_SOURCES = \
src/system/EventFD.cxx src/system/EventFD.hxx \
src/system/SignalFD.cxx src/system/SignalFD.hxx \
src/system/EPollFD.cxx src/system/EPollFD.hxx \
src/system/clock.c src/system/clock.h
src/system/Clock.cxx src/system/Clock.hxx
# Event loop library
......
......@@ -20,7 +20,7 @@
#include "config.h"
#include "Timer.hxx"
#include "AudioFormat.hxx"
#include "system/clock.h"
#include "system/Clock.hxx"
#include <glib.h>
......@@ -37,7 +37,7 @@ Timer::Timer(const AudioFormat af)
void Timer::Start()
{
time = monotonic_clock_us();
time = MonotonicClockUS();
started = true;
}
......@@ -58,7 +58,7 @@ void Timer::Add(int size)
unsigned Timer::GetDelay() const
{
int64_t delay = (int64_t)(time - monotonic_clock_us()) / 1000;
int64_t delay = (int64_t)(time - MonotonicClockUS()) / 1000;
if (delay < 0)
return 0;
......@@ -74,7 +74,7 @@ void Timer::Synchronize() const
assert(started);
sleep_duration = time - monotonic_clock_us();
sleep_duration = time - MonotonicClockUS();
if (sleep_duration > 0)
g_usleep(sleep_duration);
}
......@@ -19,10 +19,10 @@
#include "config.h"
#include "Loop.hxx"
#include "system/clock.h"
#ifdef USE_EPOLL
#include "system/Clock.hxx"
#include "TimeoutMonitor.hxx"
#include "SocketMonitor.hxx"
#include "IdleMonitor.hxx"
......@@ -31,7 +31,7 @@
EventLoop::EventLoop(Default)
:SocketMonitor(*this),
now_ms(::monotonic_clock_ms()),
now_ms(::MonotonicClockMS()),
quit(false),
n_events(0),
thread(ThreadId::Null())
......@@ -114,7 +114,7 @@ EventLoop::Run()
assert(!quit);
do {
now_ms = ::monotonic_clock_ms();
now_ms = ::MonotonicClockMS();
/* invoke timers */
......@@ -162,7 +162,7 @@ EventLoop::Run()
const int n = epoll.Wait(events, MAX_EVENTS, timeout_ms);
n_events = std::max(n, 0);
now_ms = ::monotonic_clock_ms();
now_ms = ::MonotonicClockMS();
assert(!quit);
......
/*
* Copyright (C) 2003-2012 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
......@@ -17,7 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "clock.h"
#include "Clock.hxx"
#ifdef WIN32
#include <windows.h>
......@@ -31,7 +31,7 @@
#endif
unsigned
monotonic_clock_ms(void)
MonotonicClockMS(void)
{
#ifdef WIN32
return GetTickCount();
......@@ -55,7 +55,7 @@ monotonic_clock_ms(void)
}
uint64_t
monotonic_clock_us(void)
MonotonicClockUS(void)
{
#ifdef WIN32
LARGE_INTEGER l_value, l_frequency;
......
/*
* Copyright (C) 2003-2012 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
......@@ -24,26 +24,18 @@
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Returns the value of a monotonic clock in milliseconds.
*/
gcc_pure
unsigned
monotonic_clock_ms(void);
MonotonicClockMS();
/**
* Returns the value of a monotonic clock in microseconds.
*/
gcc_pure
uint64_t
monotonic_clock_us(void);
#ifdef __cplusplus
}
#endif
MonotonicClockUS();
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment