From 86d1bf8389a49a05eebaacca5fe6c231e251775d Mon Sep 17 00:00:00 2001 From: vng Date: Sat, 6 Jun 2015 14:38:24 +0300 Subject: [PATCH] Correct ThreadChecker fix. --- base/deferred_task.cpp | 2 +- base/deferred_task.hpp | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/base/deferred_task.cpp b/base/deferred_task.cpp index 01c1b7ba5f..fac03e9ace 100644 --- a/base/deferred_task.cpp +++ b/base/deferred_task.cpp @@ -78,7 +78,7 @@ void DeferredTask::WaitForCompletion() void DeferredTask::CheckContext() const { -#if defined(DEBUG) && defined(OMIM_OS_ANDROID) +#ifdef USE_THREAD_CHECKER CHECK(m_threadChecker.CalledOnOriginalThread(), ()); #endif } diff --git a/base/deferred_task.hpp b/base/deferred_task.hpp index dfed2bea20..d47cbf58d2 100644 --- a/base/deferred_task.hpp +++ b/base/deferred_task.hpp @@ -4,15 +4,23 @@ #include "base/macros.hpp" #include "base/thread.hpp" -#ifndef OMIM_OS_ANDROID -#include "base/thread_checker.hpp" -#endif - #include "std/chrono.hpp" #include "std/condition_variable.hpp" #include "std/function.hpp" #include "std/unique_ptr.hpp" + +#if defined(DEBUG) && !defined(OMIM_OS_ANDROID) +// This checker is not valid on Android. +// UI thread (NV thread) can change it's handle value during app lifecycle. +#define USE_THREAD_CHECKER +#endif + +#ifdef USE_THREAD_CHECKER +#include "base/thread_checker.hpp" +#endif + + // This class is used to call a function after waiting for a specified // amount of time. The function is called in a separate thread. This // class is not thread safe. @@ -57,9 +65,7 @@ private: atomic m_started; threads::Thread m_thread; -#if defined(DEBUG) && defined(OMIM_OS_ANDROID) - // This checker is not valid on Android. - // UI thread (NV thread) can change it's handle value during app lifecycle. +#ifdef USE_THREAD_CHECKER ThreadChecker m_threadChecker; #endif void CheckContext() const;