thread/Slack: use std::chrono::duration

This commit is contained in:
Max Kellermann
2019-05-29 21:11:32 +02:00
parent 14cee01ba1
commit 620a39afb4
4 changed files with 10 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2003-2018 The Music Player Daemon Project
* Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -22,6 +22,8 @@
#include "config.h"
#include <chrono>
#ifdef HAVE_PRCTL
#include <sys/prctl.h>
#endif
@@ -41,16 +43,11 @@ SetThreadTimerSlackNS(unsigned long slack_ns) noexcept
#endif
}
static inline void
SetThreadTimerSlackUS(unsigned long slack_us) noexcept
template<class Rep, class Period>
static inline auto
SetThreadTimerSlack(const std::chrono::duration<Rep,Period> &slack) noexcept
{
SetThreadTimerSlackNS(slack_us * 1000ul);
}
static inline void
SetThreadTimerSlackMS(unsigned long slack_ms) noexcept
{
SetThreadTimerSlackNS(slack_ms * 1000000ul);
SetThreadTimerSlackNS(std::chrono::duration_cast<std::chrono::nanoseconds>(slack).count());
}
#endif