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
eeb96eb3
Commit
eeb96eb3
authored
Oct 08, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event/TimerEvent: add type alias for std::chrono::steady_clock::duration
parent
ce93e589
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
84 additions
and
51 deletions
+84
-51
StateFileConfig.hxx
src/StateFileConfig.hxx
+3
-4
Config.cxx
src/client/Config.cxx
+1
-1
Config.hxx
src/client/Config.hxx
+2
-2
Expire.cxx
src/client/Expire.cxx
+1
-1
InotifyQueue.cxx
src/db/update/InotifyQueue.cxx
+1
-1
Chrono.hxx
src/event/Chrono.hxx
+36
-0
Loop.cxx
src/event/Loop.cxx
+5
-5
Loop.hxx
src/event/Loop.hxx
+6
-6
MultiSocketMonitor.cxx
src/event/MultiSocketMonitor.cxx
+1
-1
MultiSocketMonitor.hxx
src/event/MultiSocketMonitor.hxx
+1
-1
TimerEvent.cxx
src/event/TimerEvent.cxx
+1
-1
TimerEvent.hxx
src/event/TimerEvent.hxx
+3
-4
AlsaInputPlugin.cxx
src/input/plugins/AlsaInputPlugin.cxx
+3
-3
NonBlock.cxx
src/lib/alsa/NonBlock.cxx
+5
-5
NonBlock.hxx
src/lib/alsa/NonBlock.hxx
+5
-6
Connection.cxx
src/lib/nfs/Connection.cxx
+1
-1
Watchdog.hxx
src/lib/systemd/Watchdog.hxx
+1
-1
AlsaMixerPlugin.cxx
src/mixer/plugins/AlsaMixerPlugin.cxx
+3
-3
AlsaOutputPlugin.cxx
src/output/plugins/AlsaOutputPlugin.cxx
+5
-5
No files found.
src/StateFileConfig.hxx
View file @
eeb96eb3
...
...
@@ -21,17 +21,16 @@
#define MPD_STATE_FILE_CONFIG_HXX
#include "fs/AllocatedPath.hxx"
#include <chrono>
#include "event/Chrono.hxx"
struct
ConfigData
;
struct
StateFileConfig
{
static
constexpr
std
::
chrono
::
steady_clock
::
d
uration
DEFAULT_INTERVAL
=
std
::
chrono
::
minutes
(
2
);
static
constexpr
Event
::
D
uration
DEFAULT_INTERVAL
=
std
::
chrono
::
minutes
(
2
);
AllocatedPath
path
;
std
::
chrono
::
steady_clock
::
d
uration
interval
;
Event
::
D
uration
interval
;
bool
restore_paused
;
...
...
src/client/Config.cxx
View file @
eeb96eb3
...
...
@@ -24,7 +24,7 @@
#define CLIENT_MAX_COMMAND_LIST_DEFAULT (2048*1024)
#define CLIENT_MAX_OUTPUT_BUFFER_SIZE_DEFAULT (8192*1024)
std
::
chrono
::
steady_clock
::
d
uration
client_timeout
;
Event
::
D
uration
client_timeout
;
size_t
client_max_command_list_size
;
size_t
client_max_output_buffer_size
;
...
...
src/client/Config.hxx
View file @
eeb96eb3
...
...
@@ -20,11 +20,11 @@
#ifndef MPD_CLIENT_CONFIG_HXX
#define MPD_CLIENT_CONFIG_HXX
#include
<chrono>
#include
"event/Chrono.hxx"
struct
ConfigData
;
extern
std
::
chrono
::
steady_clock
::
d
uration
client_timeout
;
extern
Event
::
D
uration
client_timeout
;
extern
size_t
client_max_command_list_size
;
extern
size_t
client_max_output_buffer_size
;
...
...
src/client/Expire.cxx
View file @
eeb96eb3
...
...
@@ -34,7 +34,7 @@ Client::SetExpired() noexcept
}
FullyBufferedSocket
::
Close
();
timeout_event
.
Schedule
(
std
::
chrono
::
steady_clock
::
d
uration
::
zero
());
timeout_event
.
Schedule
(
Event
::
D
uration
::
zero
());
}
void
...
...
src/db/update/InotifyQueue.cxx
View file @
eeb96eb3
...
...
@@ -29,7 +29,7 @@
* UpdateService::Enqueue(). This increases the probability that
* updates can be bundled.
*/
static
constexpr
std
::
chrono
::
steady_clock
::
d
uration
INOTIFY_UPDATE_DELAY
=
static
constexpr
Event
::
D
uration
INOTIFY_UPDATE_DELAY
=
std
::
chrono
::
seconds
(
5
);
void
...
...
src/event/Chrono.hxx
0 → 100644
View file @
eeb96eb3
/*
* Copyright 2003-2020 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_EVENT_CHRONO_HXX
#define MPD_EVENT_CHRONO_HXX
#include <chrono>
namespace
Event
{
/**
* The clock used by class #EventLoop and class #TimerEvent.
*/
using
Clock
=
std
::
chrono
::
steady_clock
;
using
Duration
=
Clock
::
duration
;
}
// namespace Event
#endif
/* MAIN_NOTIFY_H */
src/event/Loop.cxx
View file @
eeb96eb3
...
...
@@ -122,7 +122,7 @@ EventLoop::RemoveIdle(IdleMonitor &i) noexcept
}
void
EventLoop
::
AddTimer
(
TimerEvent
&
t
,
std
::
chrono
::
steady_clock
::
d
uration
d
)
noexcept
EventLoop
::
AddTimer
(
TimerEvent
&
t
,
Event
::
D
uration
d
)
noexcept
{
assert
(
IsInside
());
...
...
@@ -131,10 +131,10 @@ EventLoop::AddTimer(TimerEvent &t, std::chrono::steady_clock::duration d) noexce
again
=
true
;
}
inline
std
::
chrono
::
steady_clock
::
d
uration
inline
Event
::
D
uration
EventLoop
::
HandleTimers
()
noexcept
{
std
::
chrono
::
steady_clock
::
d
uration
timeout
;
Event
::
D
uration
timeout
;
while
(
!
quit
)
{
auto
i
=
timers
.
begin
();
...
...
@@ -151,7 +151,7 @@ EventLoop::HandleTimers() noexcept
t
.
Run
();
}
return
std
::
chrono
::
steady_clock
::
d
uration
(
-
1
);
return
Event
::
D
uration
(
-
1
);
}
/**
...
...
@@ -160,7 +160,7 @@ EventLoop::HandleTimers() noexcept
* value (= never times out) is translated to the magic value -1.
*/
static
constexpr
int
ExportTimeoutMS
(
std
::
chrono
::
steady_clock
::
d
uration
timeout
)
ExportTimeoutMS
(
Event
::
D
uration
timeout
)
{
return
timeout
>=
timeout
.
zero
()
/* round up (+1) to avoid unnecessary wakeups */
...
...
src/event/Loop.hxx
View file @
eeb96eb3
...
...
@@ -20,6 +20,7 @@
#ifndef MPD_EVENT_LOOP_HXX
#define MPD_EVENT_LOOP_HXX
#include "Chrono.hxx"
#include "PollGroup.hxx"
#include "WakeFD.hxx"
#include "SocketMonitor.hxx"
...
...
@@ -91,7 +92,7 @@ class EventLoop final : SocketMonitor
std
::
unique_ptr
<
Uring
::
Manager
>
uring
;
#endif
std
::
chrono
::
steady_clock
::
time_point
now
=
std
::
chrono
::
steady_c
lock
::
now
();
Event
::
Clock
::
time_point
now
=
Event
::
C
lock
::
now
();
/**
* Is this #EventLoop alive, i.e. can events be scheduled?
...
...
@@ -140,9 +141,9 @@ public:
~
EventLoop
()
noexcept
;
/**
* A caching wrapper for
std::chrono::steady_c
lock::now().
* A caching wrapper for
Event::C
lock::now().
*/
std
::
chrono
::
steady_clock
::
time_point
GetTime
()
const
{
auto
GetTime
()
const
{
assert
(
IsInside
());
return
now
;
...
...
@@ -184,8 +185,7 @@ public:
void
AddIdle
(
IdleMonitor
&
i
)
noexcept
;
void
RemoveIdle
(
IdleMonitor
&
i
)
noexcept
;
void
AddTimer
(
TimerEvent
&
t
,
std
::
chrono
::
steady_clock
::
duration
d
)
noexcept
;
void
AddTimer
(
TimerEvent
&
t
,
Event
::
Duration
d
)
noexcept
;
/**
* Schedule a call to DeferEvent::RunDeferred().
...
...
@@ -221,7 +221,7 @@ private:
* duration until the next timer expires. Returns a negative
* duration if there is no timeout.
*/
std
::
chrono
::
steady_clock
::
d
uration
HandleTimers
()
noexcept
;
Event
::
D
uration
HandleTimers
()
noexcept
;
bool
OnSocketReady
(
unsigned
flags
)
noexcept
override
;
...
...
src/event/MultiSocketMonitor.cxx
View file @
eeb96eb3
...
...
@@ -117,7 +117,7 @@ MultiSocketMonitor::Prepare() noexcept
/* if there was at least one file descriptor not
supported by epoll, install a very short timeout
because we assume it's always ready */
constexpr
std
::
chrono
::
steady_clock
::
d
uration
ready_timeout
=
constexpr
Event
::
D
uration
ready_timeout
=
std
::
chrono
::
milliseconds
(
1
);
if
(
timeout
<
timeout
.
zero
()
||
timeout
>
ready_timeout
)
timeout
=
ready_timeout
;
...
...
src/event/MultiSocketMonitor.hxx
View file @
eeb96eb3
...
...
@@ -226,7 +226,7 @@ protected:
*
* @return timeout or a negative value for no timeout
*/
virtual
std
::
chrono
::
steady_clock
::
d
uration
PrepareSockets
()
noexcept
=
0
;
virtual
Event
::
D
uration
PrepareSockets
()
noexcept
=
0
;
/**
* At least one socket is ready or the timeout has expired.
...
...
src/event/TimerEvent.cxx
View file @
eeb96eb3
...
...
@@ -21,7 +21,7 @@
#include "Loop.hxx"
void
TimerEvent
::
Schedule
(
std
::
chrono
::
steady_clock
::
d
uration
d
)
noexcept
TimerEvent
::
Schedule
(
Event
::
D
uration
d
)
noexcept
{
Cancel
();
...
...
src/event/TimerEvent.hxx
View file @
eeb96eb3
...
...
@@ -20,12 +20,11 @@
#ifndef MPD_TIMER_EVENT_HXX
#define MPD_TIMER_EVENT_HXX
#include "Chrono.hxx"
#include "util/BindMethod.hxx"
#include <boost/intrusive/set_hook.hpp>
#include <chrono>
class
EventLoop
;
/**
...
...
@@ -50,7 +49,7 @@ class TimerEvent final
* When is this timer due? This is only valid if IsActive()
* returns true.
*/
std
::
chrono
::
steady_c
lock
::
time_point
due
;
Event
::
C
lock
::
time_point
due
;
public
:
TimerEvent
(
EventLoop
&
_loop
,
Callback
_callback
)
noexcept
...
...
@@ -65,7 +64,7 @@ public:
return
is_linked
();
}
void
Schedule
(
std
::
chrono
::
steady_clock
::
d
uration
d
)
noexcept
;
void
Schedule
(
Event
::
D
uration
d
)
noexcept
;
void
Cancel
()
noexcept
{
unlink
();
...
...
src/input/plugins/AlsaInputPlugin.cxx
View file @
eeb96eb3
...
...
@@ -127,7 +127,7 @@ private:
int
Recover
(
int
err
);
/* virtual methods from class MultiSocketMonitor */
std
::
chrono
::
steady_clock
::
d
uration
PrepareSockets
()
noexcept
override
;
Event
::
D
uration
PrepareSockets
()
noexcept
override
;
void
DispatchSockets
()
noexcept
override
;
};
...
...
@@ -219,12 +219,12 @@ AlsaInputStream::Create(EventLoop &event_loop, const char *uri,
return
std
::
make_unique
<
AlsaInputStream
>
(
event_loop
,
mutex
,
spec
);
}
std
::
chrono
::
steady_clock
::
d
uration
Event
::
D
uration
AlsaInputStream
::
PrepareSockets
()
noexcept
{
if
(
IsPaused
())
{
ClearSocketList
();
return
std
::
chrono
::
steady_clock
::
d
uration
(
-
1
);
return
Event
::
D
uration
(
-
1
);
}
return
non_block
.
PrepareSockets
(
*
this
,
capture_handle
);
...
...
src/lib/alsa/NonBlock.cxx
View file @
eeb96eb3
...
...
@@ -21,7 +21,7 @@
#include "event/MultiSocketMonitor.hxx"
#include "util/RuntimeError.hxx"
std
::
chrono
::
steady_clock
::
d
uration
Event
::
D
uration
AlsaNonBlockPcm
::
PrepareSockets
(
MultiSocketMonitor
&
m
,
snd_pcm_t
*
pcm
)
{
int
count
=
snd_pcm_poll_descriptors_count
(
pcm
);
...
...
@@ -45,7 +45,7 @@ AlsaNonBlockPcm::PrepareSockets(MultiSocketMonitor &m, snd_pcm_t *pcm)
}
m
.
ReplaceSocketList
(
pfds
,
count
);
return
std
::
chrono
::
steady_clock
::
d
uration
(
-
1
);
return
Event
::
D
uration
(
-
1
);
}
void
...
...
@@ -75,13 +75,13 @@ AlsaNonBlockPcm::DispatchSockets(MultiSocketMonitor &m,
snd_strerror
(
-
err
));
}
std
::
chrono
::
steady_clock
::
d
uration
Event
::
D
uration
AlsaNonBlockMixer
::
PrepareSockets
(
MultiSocketMonitor
&
m
,
snd_mixer_t
*
mixer
)
noexcept
{
int
count
=
snd_mixer_poll_descriptors_count
(
mixer
);
if
(
count
<=
0
)
{
m
.
ClearSocketList
();
return
std
::
chrono
::
steady_clock
::
d
uration
(
-
1
);
return
Event
::
D
uration
(
-
1
);
}
struct
pollfd
*
pfds
=
pfd_buffer
.
Get
(
count
);
...
...
@@ -91,7 +91,7 @@ AlsaNonBlockMixer::PrepareSockets(MultiSocketMonitor &m, snd_mixer_t *mixer) noe
count
=
0
;
m
.
ReplaceSocketList
(
pfds
,
count
);
return
std
::
chrono
::
steady_clock
::
d
uration
(
-
1
);
return
Event
::
D
uration
(
-
1
);
}
void
...
...
src/lib/alsa/NonBlock.hxx
View file @
eeb96eb3
...
...
@@ -20,12 +20,11 @@
#ifndef MPD_ALSA_NON_BLOCK_HXX
#define MPD_ALSA_NON_BLOCK_HXX
#include "event/Chrono.hxx"
#include "util/ReusableArray.hxx"
#include <alsa/asoundlib.h>
#include <chrono>
class
MultiSocketMonitor
;
/**
...
...
@@ -39,8 +38,8 @@ public:
/**
* Throws on error.
*/
std
::
chrono
::
steady_clock
::
d
uration
PrepareSockets
(
MultiSocketMonitor
&
m
,
snd_pcm_t
*
pcm
);
Event
::
D
uration
PrepareSockets
(
MultiSocketMonitor
&
m
,
snd_pcm_t
*
pcm
);
/**
* Wrapper for snd_pcm_poll_descriptors_revents(), to be
...
...
@@ -59,8 +58,8 @@ class AlsaNonBlockMixer {
ReusableArray
<
pollfd
>
pfd_buffer
;
public
:
std
::
chrono
::
steady_clock
::
d
uration
PrepareSockets
(
MultiSocketMonitor
&
m
,
snd_mixer_t
*
mixer
)
noexcept
;
Event
::
D
uration
PrepareSockets
(
MultiSocketMonitor
&
m
,
snd_mixer_t
*
mixer
)
noexcept
;
/**
* Wrapper for snd_mixer_poll_descriptors_revents(), to be
...
...
src/lib/nfs/Connection.cxx
View file @
eeb96eb3
...
...
@@ -37,7 +37,7 @@ extern "C" {
#include <poll.h>
/* for POLLIN, POLLOUT */
#endif
static
constexpr
std
::
chrono
::
steady_clock
::
d
uration
NFS_MOUNT_TIMEOUT
=
static
constexpr
Event
::
D
uration
NFS_MOUNT_TIMEOUT
=
std
::
chrono
::
minutes
(
1
);
inline
void
...
...
src/lib/systemd/Watchdog.hxx
View file @
eeb96eb3
...
...
@@ -42,7 +42,7 @@ namespace Systemd {
class
Watchdog
{
TimerEvent
timer
;
std
::
chrono
::
steady_clock
::
d
uration
interval
;
Event
::
D
uration
interval
;
public
:
explicit
Watchdog
(
EventLoop
&
_loop
)
noexcept
;
...
...
src/mixer/plugins/AlsaMixerPlugin.cxx
View file @
eeb96eb3
...
...
@@ -64,7 +64,7 @@ public:
}
private
:
std
::
chrono
::
steady_clock
::
d
uration
PrepareSockets
()
noexcept
override
;
Event
::
D
uration
PrepareSockets
()
noexcept
override
;
void
DispatchSockets
()
noexcept
override
;
};
...
...
@@ -99,12 +99,12 @@ public:
static
constexpr
Domain
alsa_mixer_domain
(
"alsa_mixer"
);
std
::
chrono
::
steady_clock
::
d
uration
Event
::
D
uration
AlsaMixerMonitor
::
PrepareSockets
()
noexcept
{
if
(
mixer
==
nullptr
)
{
ClearSocketList
();
return
std
::
chrono
::
steady_clock
::
d
uration
(
-
1
);
return
Event
::
D
uration
(
-
1
);
}
return
non_block
.
PrepareSockets
(
*
this
,
mixer
);
...
...
src/output/plugins/AlsaOutputPlugin.cxx
View file @
eeb96eb3
...
...
@@ -119,7 +119,7 @@ class AlsaOutput final
*/
snd_pcm_uframes_t
period_frames
;
std
::
chrono
::
steady_clock
::
d
uration
effective_period_duration
;
Event
::
D
uration
effective_period_duration
;
/**
* If snd_pcm_avail() goes above this value and no more data
...
...
@@ -398,7 +398,7 @@ private:
}
/* virtual methods from class MultiSocketMonitor */
std
::
chrono
::
steady_clock
::
d
uration
PrepareSockets
()
noexcept
override
;
Event
::
D
uration
PrepareSockets
()
noexcept
override
;
void
DispatchSockets
()
noexcept
override
;
};
...
...
@@ -1052,12 +1052,12 @@ AlsaOutput::Play(const void *chunk, size_t size)
return
size
;
}
std
::
chrono
::
steady_clock
::
d
uration
Event
::
D
uration
AlsaOutput
::
PrepareSockets
()
noexcept
{
if
(
!
LockIsActiveAndNotWaiting
())
{
ClearSocketList
();
return
std
::
chrono
::
steady_clock
::
d
uration
(
-
1
);
return
Event
::
D
uration
(
-
1
);
}
try
{
...
...
@@ -1065,7 +1065,7 @@ AlsaOutput::PrepareSockets() noexcept
}
catch
(...)
{
ClearSocketList
();
LockCaughtError
();
return
std
::
chrono
::
steady_clock
::
d
uration
(
-
1
);
return
Event
::
D
uration
(
-
1
);
}
}
...
...
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