event/TimerEvent: add type alias for std::chrono::steady_clock::duration

This commit is contained in:
Max Kellermann
2020-10-08 19:35:36 +02:00
parent ce93e58944
commit eeb96eb367
19 changed files with 84 additions and 51 deletions

View File

@@ -21,7 +21,7 @@
#include "event/MultiSocketMonitor.hxx"
#include "util/RuntimeError.hxx"
std::chrono::steady_clock::duration
Event::Duration
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::duration(-1);
return Event::Duration(-1);
}
void
@@ -75,13 +75,13 @@ AlsaNonBlockPcm::DispatchSockets(MultiSocketMonitor &m,
snd_strerror(-err));
}
std::chrono::steady_clock::duration
Event::Duration
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::duration(-1);
return Event::Duration(-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::duration(-1);
return Event::Duration(-1);
}
void

View File

@@ -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::duration PrepareSockets(MultiSocketMonitor &m,
snd_pcm_t *pcm);
Event::Duration 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::duration PrepareSockets(MultiSocketMonitor &m,
snd_mixer_t *mixer) noexcept;
Event::Duration PrepareSockets(MultiSocketMonitor &m,
snd_mixer_t *mixer) noexcept;
/**
* Wrapper for snd_mixer_poll_descriptors_revents(), to be

View File

@@ -37,7 +37,7 @@ extern "C" {
#include <poll.h> /* for POLLIN, POLLOUT */
#endif
static constexpr std::chrono::steady_clock::duration NFS_MOUNT_TIMEOUT =
static constexpr Event::Duration NFS_MOUNT_TIMEOUT =
std::chrono::minutes(1);
inline void

View File

@@ -42,7 +42,7 @@ namespace Systemd {
class Watchdog {
TimerEvent timer;
std::chrono::steady_clock::duration interval;
Event::Duration interval;
public:
explicit Watchdog(EventLoop &_loop) noexcept;