Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
0c13703d
Commit
0c13703d
authored
Oct 15, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
system/clock: convert to C++
parent
b97b7a74
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
24 deletions
+16
-24
Makefile.am
Makefile.am
+1
-1
Timer.cxx
src/Timer.cxx
+4
-4
Loop.cxx
src/event/Loop.cxx
+4
-4
Clock.cxx
src/system/Clock.cxx
+4
-4
Clock.hxx
src/system/Clock.hxx
+3
-11
No files found.
Makefile.am
View file @
0c13703d
...
...
@@ -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
...
...
src/Timer.cxx
View file @
0c13703d
...
...
@@ -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
);
}
src/event/Loop.cxx
View file @
0c13703d
...
...
@@ -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
);
...
...
src/system/
clock.c
→
src/system/
Clock.cxx
View file @
0c13703d
/*
* Copyright (C) 2003-201
2
The Music Player Daemon Project
* Copyright (C) 2003-201
3
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
;
...
...
src/system/
clock.h
→
src/system/
Clock.hxx
View file @
0c13703d
/*
* Copyright (C) 2003-201
2
The Music Player Daemon Project
* Copyright (C) 2003-201
3
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment