From 4b40a7eb319f8cb63c475056d5824cf3127f341e Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Mon, 14 Jun 2021 14:55:08 +0200 Subject: [PATCH] backward-compatible Timer interface --- libsrc/core/profiler.hpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libsrc/core/profiler.hpp b/libsrc/core/profiler.hpp index 0b647d82..c7a60af9 100644 --- a/libsrc/core/profiler.hpp +++ b/libsrc/core/profiler.hpp @@ -188,6 +188,8 @@ namespace ngcore Timer( const std::string & name, TTracing, TTiming ) : timernr(Init(name)) { } + [[deprecated ("Use Timer(name, NoTracing/NoTiming) instead")]] Timer( const std::string & name, int ) : timernr(Init(name)) {} + void SetName (const std::string & name) { NgProfiler::SetName (timernr, name); @@ -276,6 +278,25 @@ namespace ngcore void operator=(RegionTimer &&) = delete; }; + class [[deprecated("Use RegionTimer instead (now thread safe)")]] ThreadRegionTimer + { + size_t nr; + size_t tid; + public: + /// start timer + ThreadRegionTimer (size_t _nr, size_t _tid) : nr(_nr), tid(_tid) + { NgProfiler::StartThreadTimer(nr, tid); } + /// stop timer + ~ThreadRegionTimer () + { NgProfiler::StopThreadTimer(nr, tid); } + + ThreadRegionTimer() = delete; + ThreadRegionTimer(ThreadRegionTimer &&) = delete; + ThreadRegionTimer(const ThreadRegionTimer &) = delete; + void operator=(const ThreadRegionTimer &) = delete; + void operator=(ThreadRegionTimer &&) = delete; + }; + class RegionTracer { int nr;