Review fixes

This commit is contained in:
Roman Kuznetsov 2015-09-25 20:53:25 +03:00 committed by r.kuznetsov
parent 84627f5b73
commit 44f3578c79
2 changed files with 8 additions and 8 deletions

View file

@ -165,7 +165,7 @@ bool Framework::CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi
m_work.CreateDrapeEngine(make_ref(m_contextFactory), move(p));
m_work.EnterForeground();
// load initial state of the map or execute drape tasks which set up custom state
// Load initial state of the map or execute drape tasks which set up custom state.
{
lock_guard<mutex> lock(m_drapeQueueMutex);
if (m_drapeTasksQueue.empty())
@ -592,21 +592,20 @@ void Framework::InjectMetadata(JNIEnv * env, jclass const clazz, jobject const m
}
}
void Framework::PostDrapeTask(TDrapeTask const & task)
void Framework::PostDrapeTask(TDrapeTask && task)
{
ASSERT(task != nullptr, ());
lock_guard<mutex> lock(m_drapeQueueMutex);
if (IsDrapeEngineCreated())
task();
else
m_drapeTasksQueue.push_back(task);
m_drapeTasksQueue.push_back(move(task));
}
void Framework::ExecuteDrapeTasks()
{
for (size_t i = 0; i < m_drapeTasksQueue.size(); ++i)
m_drapeTasksQueue[i]();
for (auto & task : m_drapeTasksQueue)
task();
m_drapeTasksQueue.clear();
}

View file

@ -161,8 +161,8 @@ namespace android
void InjectMetadata(JNIEnv * env, jclass clazz, jobject const mapObject, UserMark const * userMark);
using TDrapeTask = function<void()>;
// Posts a task which must be executed when Drape Engine is alive
void PostDrapeTask(TDrapeTask const & task);
// Posts a task which must be executed when Drape Engine is alive.
void PostDrapeTask(TDrapeTask && task);
public:
virtual void ItemStatusChanged(int childPosition);
@ -182,6 +182,7 @@ namespace android
vector<TDrapeTask> m_drapeTasksQueue;
mutex m_drapeQueueMutex;
// This method must be executed under mutex m_drapeQueueMutex.
void ExecuteDrapeTasks();
};
}