From 59b21e67dd7b3aca60c21d46ed8262415392a4c0 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sat, 30 Dec 2017 13:38:11 +1100 Subject: [PATCH] time: more inline implementation into the header --- CMakeLists.txt | 1 - time.hpp | 30 ++++++++++++++++++++---------- time.ipp | 28 ---------------------------- 3 files changed, 20 insertions(+), 39 deletions(-) delete mode 100644 time.ipp diff --git a/CMakeLists.txt b/CMakeLists.txt index f7895cb8..20729385 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -400,7 +400,6 @@ list ( term.hpp time.cpp time.hpp - time.ipp tuple.cpp tuple.hpp typeidx.cpp diff --git a/time.hpp b/time.hpp index 60c12b1a..24ffed5a 100644 --- a/time.hpp +++ b/time.hpp @@ -25,15 +25,24 @@ namespace util { - // ------------------------------------------------------------------------ + /////////////////////////////////////////////////////////////////////////// uintmax_t nanoseconds (void); - template - void sleep (std::chrono::duration); + //------------------------------------------------------------------------- + template + void sleep (std::chrono::duration dt) + { + auto nano = std::chrono::duration_cast (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 diff --git a/time.ipp b/time.ipp deleted file mode 100644 index a1c1604b..00000000 --- a/time.ipp +++ /dev/null @@ -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 - */ - -#ifndef __UTIL_TIME_IPP -#define __UTIL_TIME_IPP - -template -void -util::sleep (std::chrono::duration dt) -{ - auto nano = std::chrono::duration_cast (dt); - sleep (nano.count ()); -} - -#endif