diff options
author | Andriy Kozoriz <AKozoriz@luxoft.com> | 2016-02-09 16:41:43 +0200 |
---|---|---|
committer | Kozoriz <kozorizandriy@gmail.com> | 2016-02-17 10:15:39 +0200 |
commit | 56382d965881bd9833170cf82bfa8bb3bfdbce60 (patch) | |
tree | 9d230b100be57942b138dcf19590c5c4271bc67c /src/components | |
parent | 62020ab881c9e12bb1bedc13d55d72912266d6a1 (diff) | |
download | sdl_core-56382d965881bd9833170cf82bfa8bb3bfdbce60.tar.gz |
Integration of Timer to UsageStatistics
TImerTHread removed.
Usage of timers updated.
Related to : APPLINK-10003
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/policy/src/policy/usage_statistics/include/usage_statistics/counter.h | 9 | ||||
-rw-r--r-- | src/components/policy/src/policy/usage_statistics/src/counter.cc | 38 |
2 files changed, 23 insertions, 24 deletions
diff --git a/src/components/policy/src/policy/usage_statistics/include/usage_statistics/counter.h b/src/components/policy/src/policy/usage_statistics/include/usage_statistics/counter.h index 6ccfb0a426..c42e22c9de 100644 --- a/src/components/policy/src/policy/usage_statistics/include/usage_statistics/counter.h +++ b/src/components/policy/src/policy/usage_statistics/include/usage_statistics/counter.h @@ -36,10 +36,12 @@ #include <ctime> #include "usage_statistics/statistics_manager.h" #include "utils/shared_ptr.h" -#include "utils/timer_thread.h" +#include "utils/timer.h" namespace usage_statistics { +using timer::Timer; + class GlobalCounter { public: GlobalCounter(utils::SharedPtr<usage_statistics::StatisticsManager> statistics_manager, @@ -80,7 +82,7 @@ class AppStopwatch { const std::string& app_id); AppStopwatch(utils::SharedPtr<usage_statistics::StatisticsManager> statistics_manager, const std::string& app_id, - std::uint32_t time_out); + std::uint32_t timeout); ~AppStopwatch(); void Start(AppStopwatchId stopwatch_type); void Switch(AppStopwatchId stopwatch_type); @@ -90,8 +92,7 @@ class AppStopwatch { std::string app_id_; AppStopwatchId stopwatch_type_; utils::SharedPtr<usage_statistics::StatisticsManager> statistics_manager_; - typedef timer::TimerThread<AppStopwatch> Timer; - Timer* timer_; + timer::Timer timer_; const std::uint32_t time_out_; }; diff --git a/src/components/policy/src/policy/usage_statistics/src/counter.cc b/src/components/policy/src/policy/usage_statistics/src/counter.cc index 92b68ffe01..e6b3d36f00 100644 --- a/src/components/policy/src/policy/usage_statistics/src/counter.cc +++ b/src/components/policy/src/policy/usage_statistics/src/counter.cc @@ -36,6 +36,8 @@ #include <cassert> #include "usage_statistics/counter.h" #include "utils/date_time.h" +#include "utils/make_shared.h" +#include "utils/timer_task_impl.h" namespace usage_statistics { @@ -79,36 +81,32 @@ void AppInfo::Update(const std::string& new_info) const { } } -AppStopwatch::AppStopwatch(utils::SharedPtr<usage_statistics::StatisticsManager> statistics_manager, - const std::string& app_id) +AppStopwatch::AppStopwatch( + utils::SharedPtr<usage_statistics::StatisticsManager> statistics_manager, + const std::string& app_id) : app_id_(app_id), stopwatch_type_(SECONDS_HMI_NONE), statistics_manager_(statistics_manager), - timer_(new Timer("HMI levels timer",this, &AppStopwatch::WriteTime, true)), - time_out_(60) { -} - -AppStopwatch::AppStopwatch(utils::SharedPtr<StatisticsManager> statistics_manager, - const std::string& app_id, - std::uint32_t time_out) - : app_id_(app_id), - stopwatch_type_(SECONDS_HMI_NONE), - statistics_manager_(statistics_manager), - timer_(new Timer("HMI levels timer",this, &AppStopwatch::WriteTime, true)), - time_out_(time_out) { + timer_("HMI levels timer", + new timer::TimerTaskImpl<AppStopwatch>(this, &AppStopwatch::WriteTime)), + time_out_(60) {} -} +AppStopwatch::AppStopwatch( + utils::SharedPtr<StatisticsManager> statistics_manager, + const std::string& app_id, uint32_t timeout) + : app_id_(app_id), + stopwatch_type_(SECONDS_HMI_NONE), + statistics_manager_(statistics_manager), + timer_("HMI levels timer", + new timer::TimerTaskImpl<AppStopwatch>(this, &AppStopwatch::WriteTime)), + time_out_(timeout) {} AppStopwatch::~AppStopwatch() { - if (NULL != timer_) { - timer_->stop(); - delete timer_; - } } void AppStopwatch::Start(AppStopwatchId stopwatch_type) { stopwatch_type_ = stopwatch_type; - timer_->start(time_out_ * date_time::DateTime::MILLISECONDS_IN_SECOND ); + timer_.Start(time_out_ * date_time::DateTime::MILLISECONDS_IN_SECOND, true); } void AppStopwatch::Switch(AppStopwatchId stopwatch_type) { |