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
96f88927
Commit
96f88927
authored
May 08, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
system/Clock: GetProcessUptimeS() returns std::chrono::duration
parent
214ddee2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
9 deletions
+13
-9
Stats.cxx
src/Stats.cxx
+6
-4
Clock.cxx
src/system/Clock.cxx
+3
-3
Clock.hxx
src/system/Clock.hxx
+4
-2
No files found.
src/Stats.cxx
View file @
96f88927
...
@@ -114,13 +114,15 @@ db_stats_print(Response &r, const Database &db)
...
@@ -114,13 +114,15 @@ db_stats_print(Response &r, const Database &db)
void
void
stats_print
(
Response
&
r
,
const
Partition
&
partition
)
stats_print
(
Response
&
r
,
const
Partition
&
partition
)
{
{
r
.
Format
(
"uptime: %u
\n
"
"playtime: %lu
\n
"
,
#ifdef _WIN32
#ifdef _WIN32
GetProcessUptimeS
(),
const
auto
uptime
=
GetProcessUptimeS
();
#else
#else
(
unsigned
)
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
std
::
chrono
::
steady_clock
::
now
()
-
start_time
).
count
(),
const
auto
uptime
=
std
::
chrono
::
steady_clock
::
now
()
-
start_time
;
#endif
#endif
r
.
Format
(
"uptime: %u
\n
"
"playtime: %lu
\n
"
,
(
unsigned
)
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
uptime
).
count
(),
std
::
lround
(
partition
.
pc
.
GetTotalPlayTime
().
count
()));
std
::
lround
(
partition
.
pc
.
GetTotalPlayTime
().
count
()));
#ifdef ENABLE_DATABASE
#ifdef ENABLE_DATABASE
...
...
src/system/Clock.cxx
View file @
96f88927
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
#include <windows.h>
#include <windows.h>
gcc_const
gcc_const
static
unsigned
static
std
::
chrono
::
seconds
DeltaFileTimeS
(
FILETIME
a
,
FILETIME
b
)
DeltaFileTimeS
(
FILETIME
a
,
FILETIME
b
)
{
{
ULARGE_INTEGER
a2
,
b2
;
ULARGE_INTEGER
a2
,
b2
;
...
@@ -31,10 +31,10 @@ DeltaFileTimeS(FILETIME a, FILETIME b)
...
@@ -31,10 +31,10 @@ DeltaFileTimeS(FILETIME a, FILETIME b)
b2
.
HighPart
=
b
.
dwHighDateTime
;
b2
.
HighPart
=
b
.
dwHighDateTime
;
a2
.
LowPart
=
a
.
dwLowDateTime
;
a2
.
LowPart
=
a
.
dwLowDateTime
;
a2
.
HighPart
=
a
.
dwHighDateTime
;
a2
.
HighPart
=
a
.
dwHighDateTime
;
return
(
a2
.
QuadPart
-
b2
.
QuadPart
)
/
10000000
;
return
std
::
chrono
::
seconds
((
a2
.
QuadPart
-
b2
.
QuadPart
)
/
10000000
)
;
}
}
unsigned
std
::
chrono
::
seconds
GetProcessUptimeS
()
GetProcessUptimeS
()
{
{
FILETIME
creation_time
,
exit_time
,
kernel_time
,
user_time
,
now
;
FILETIME
creation_time
,
exit_time
,
kernel_time
,
user_time
,
now
;
...
...
src/system/Clock.hxx
View file @
96f88927
/*
/*
* Copyright 2003-201
8
The Music Player Daemon Project
* Copyright 2003-201
9
The Music Player Daemon Project
* http://www.musicpd.org
* http://www.musicpd.org
*
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
...
@@ -22,13 +22,15 @@
...
@@ -22,13 +22,15 @@
#include "util/Compiler.h"
#include "util/Compiler.h"
#include <chrono>
#ifdef _WIN32
#ifdef _WIN32
/**
/**
* Returns the uptime of the current process in seconds.
* Returns the uptime of the current process in seconds.
*/
*/
gcc_pure
gcc_pure
unsigned
std
::
chrono
::
seconds
GetProcessUptimeS
();
GetProcessUptimeS
();
#endif
#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