From 8acb7b41f83a192833ffe6b6339aaacc87f3d4cd Mon Sep 17 00:00:00 2001 From: lijincheng Date: Wed, 15 Nov 2023 15:57:48 +0800 Subject: [PATCH] Sasdk rectification 2 1. Move the event_reactor.h from base/src to base/include 2. Change all methods to private and add friend class Issue:https://gitee.com/openharmony/commonlibrary_c_utils/issues/I8FRNJ Signed-off-by: lijincheng --- base/include/timer.h | 7 +++---- base/src/timer.cpp | 6 ++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/base/include/timer.h b/base/include/timer.h index acc760b..01e31d2 100644 --- a/base/include/timer.h +++ b/base/include/timer.h @@ -25,10 +25,9 @@ #include #include -#include "../src/event_reactor.h" - namespace OHOS { namespace Utils { +class EventReactor; /** * @brief Implements a timer manager. * @@ -69,7 +68,7 @@ public: * triggered). `0` means not to wait, which occupies too much CPU time. */ explicit Timer(const std::string& name, int timeoutMs = 1000); - virtual ~Timer() {} + virtual ~Timer(); /** * @brief Sets up a timer. @@ -142,7 +141,7 @@ private: std::string name_; int timeoutMs_; std::thread thread_; - std::unique_ptr reactor_; + EventReactor *reactor_; std::map timers_; // timer_fd to interval std::mutex mutex_; }; diff --git a/base/src/timer.cpp b/base/src/timer.cpp index fa6109e..4d80e67 100644 --- a/base/src/timer.cpp +++ b/base/src/timer.cpp @@ -14,6 +14,7 @@ */ #include "timer.h" +#include "event_reactor.h" #include #include "common_timer_errors.h" @@ -29,6 +30,11 @@ Timer::Timer(const std::string& name, int timeoutMs) : name_(name), timeoutMs_(t { } +Timer::~Timer() +{ + delete reactor_; +} + uint32_t Timer::Setup() { if (thread_.joinable()) { // avoid double assign to an active thread -- Gitee