thread/Slack: use std::chrono::duration
This commit is contained in:
parent
14cee01ba1
commit
620a39afb4
@ -589,7 +589,7 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
|
|||||||
|
|
||||||
/* the MPD frontend does not care about timer slack; set it to
|
/* the MPD frontend does not care about timer slack; set it to
|
||||||
a huge value to allow the kernel to reduce CPU wakeups */
|
a huge value to allow the kernel to reduce CPU wakeups */
|
||||||
SetThreadTimerSlackMS(100);
|
SetThreadTimerSlack(std::chrono::milliseconds(100));
|
||||||
|
|
||||||
#ifdef ENABLE_SYSTEMD_DAEMON
|
#ifdef ENABLE_SYSTEMD_DAEMON
|
||||||
sd_notify(0, "READY=1");
|
sd_notify(0, "READY=1");
|
||||||
|
@ -52,7 +52,7 @@ EventThread::Run() noexcept
|
|||||||
SetThreadName(realtime ? "rtio" : "io");
|
SetThreadName(realtime ? "rtio" : "io");
|
||||||
|
|
||||||
if (realtime) {
|
if (realtime) {
|
||||||
SetThreadTimerSlackUS(10);
|
SetThreadTimerSlack(std::chrono::microseconds(10));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SetThreadRealtime();
|
SetThreadRealtime();
|
||||||
|
@ -410,7 +410,7 @@ AudioOutputControl::Task() noexcept
|
|||||||
"OutputThread could not get realtime scheduling, continuing anyway");
|
"OutputThread could not get realtime scheduling, continuing anyway");
|
||||||
}
|
}
|
||||||
|
|
||||||
SetThreadTimerSlackUS(100);
|
SetThreadTimerSlack(std::chrono::microseconds(100));
|
||||||
|
|
||||||
std::unique_lock<Mutex> lock(mutex);
|
std::unique_lock<Mutex> lock(mutex);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2018 The Music Player Daemon Project
|
* Copyright 2003-2019 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,6 +22,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#ifdef HAVE_PRCTL
|
#ifdef HAVE_PRCTL
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
#endif
|
#endif
|
||||||
@ -41,16 +43,11 @@ SetThreadTimerSlackNS(unsigned long slack_ns) noexcept
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
template<class Rep, class Period>
|
||||||
SetThreadTimerSlackUS(unsigned long slack_us) noexcept
|
static inline auto
|
||||||
|
SetThreadTimerSlack(const std::chrono::duration<Rep,Period> &slack) noexcept
|
||||||
{
|
{
|
||||||
SetThreadTimerSlackNS(slack_us * 1000ul);
|
SetThreadTimerSlackNS(std::chrono::duration_cast<std::chrono::nanoseconds>(slack).count());
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
SetThreadTimerSlackMS(unsigned long slack_ms) noexcept
|
|
||||||
{
|
|
||||||
SetThreadTimerSlackNS(slack_ms * 1000000ul);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user