time: more inline implementation into the header
This commit is contained in:
parent
f2fa90d043
commit
59b21e67dd
@ -400,7 +400,6 @@ list (
|
||||
term.hpp
|
||||
time.cpp
|
||||
time.hpp
|
||||
time.ipp
|
||||
tuple.cpp
|
||||
tuple.hpp
|
||||
typeidx.cpp
|
||||
|
30
time.hpp
30
time.hpp
@ -25,15 +25,24 @@
|
||||
|
||||
|
||||
namespace util {
|
||||
// ------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
uintmax_t nanoseconds (void);
|
||||
|
||||
template <typename T>
|
||||
void sleep (std::chrono::duration<T,std::nano>);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void sleep (std::chrono::duration<T,std::nano> dt)
|
||||
{
|
||||
auto nano = std::chrono::duration_cast<std::chrono::nanoseconds> (dt);
|
||||
sleep (nano.count ());
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void sleep (uint64_t ns);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
class delta_clock {
|
||||
public:
|
||||
delta_clock ();
|
||||
@ -46,7 +55,8 @@ namespace util {
|
||||
} time;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
class period_query {
|
||||
public:
|
||||
explicit period_query (float seconds);
|
||||
@ -60,7 +70,8 @@ namespace util {
|
||||
} m_time;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
class rate_limiter {
|
||||
public:
|
||||
explicit rate_limiter (unsigned rate);
|
||||
@ -72,7 +83,8 @@ namespace util {
|
||||
unsigned m_target;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
class polled_duration {
|
||||
public:
|
||||
polled_duration (std::string name, uint64_t interval);
|
||||
@ -90,6 +102,4 @@ namespace util {
|
||||
};
|
||||
}
|
||||
|
||||
#include "time.ipp"
|
||||
|
||||
#endif // __UTIL_TIME_HPP
|
||||
#endif
|
||||
|
28
time.ipp
28
time.ipp
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Copyright 2016 Danny Robson <danny@nerdcruft.net>
|
||||
*/
|
||||
|
||||
#ifndef __UTIL_TIME_IPP
|
||||
#define __UTIL_TIME_IPP
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
util::sleep (std::chrono::duration<T,std::nano> dt)
|
||||
{
|
||||
auto nano = std::chrono::duration_cast<std::chrono::nanoseconds> (dt);
|
||||
sleep (nano.count ());
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user