forked from organicmaps/organicmaps-tmp
Removed thread checker due to Android and NV thread. It’s handle can be changed in runtime.
This commit is contained in:
parent
054b4dfdef
commit
b3bf7f96e8
2 changed files with 23 additions and 5 deletions
|
@ -48,19 +48,22 @@ DeferredTask::DeferredTask(TTask const & task, milliseconds ms) : m_started(fals
|
|||
|
||||
DeferredTask::~DeferredTask()
|
||||
{
|
||||
ASSERT(m_threadChecker.CalledOnOriginalThread(), ());
|
||||
CheckContext();
|
||||
|
||||
m_thread.Cancel();
|
||||
}
|
||||
|
||||
bool DeferredTask::WasStarted() const
|
||||
{
|
||||
ASSERT(m_threadChecker.CalledOnOriginalThread(), ());
|
||||
CheckContext();
|
||||
|
||||
return m_started;
|
||||
}
|
||||
|
||||
void DeferredTask::Cancel()
|
||||
{
|
||||
ASSERT(m_threadChecker.CalledOnOriginalThread(), ());
|
||||
CheckContext();
|
||||
|
||||
threads::IRoutine * routine = m_thread.GetRoutine();
|
||||
CHECK(routine, ());
|
||||
routine->Cancel();
|
||||
|
@ -68,6 +71,14 @@ void DeferredTask::Cancel()
|
|||
|
||||
void DeferredTask::WaitForCompletion()
|
||||
{
|
||||
ASSERT(m_threadChecker.CalledOnOriginalThread(), ());
|
||||
CheckContext();
|
||||
|
||||
m_thread.Join();
|
||||
}
|
||||
|
||||
void DeferredTask::CheckContext() const
|
||||
{
|
||||
#if defined(DEBUG) && defined(OMIM_OS_ANDROID)
|
||||
CHECK(m_threadChecker.CalledOnOriginalThread(), ());
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
#include "base/condition.hpp"
|
||||
#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"
|
||||
|
@ -53,9 +56,13 @@ private:
|
|||
/// is used by routine that will be executed on m_thread.
|
||||
atomic<bool> m_started;
|
||||
threads::Thread m_thread;
|
||||
#ifdef DEBUG
|
||||
|
||||
#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.
|
||||
ThreadChecker m_threadChecker;
|
||||
#endif
|
||||
void CheckContext() const;
|
||||
|
||||
DISALLOW_COPY_AND_MOVE(DeferredTask);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue