mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-28 17:03:38 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
32
storage/storage_tests/task_runner.hpp
Normal file
32
storage/storage_tests/task_runner.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include "base/thread_checker.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <queue>
|
||||
|
||||
namespace storage
|
||||
{
|
||||
// This class can be used in tests to mimic asynchronious calls. For
|
||||
// example, when task A invokes task B and passes a callback C as an
|
||||
// argument to B, it's silly for B to call C directly if B is an
|
||||
// asynchronious task. So, the solution is to post C on the same
|
||||
// message loop where B is run.
|
||||
//
|
||||
// *NOTE*, this class is not thread-safe.
|
||||
class TaskRunner
|
||||
{
|
||||
public:
|
||||
using TTask = std::function<void()>;
|
||||
|
||||
~TaskRunner();
|
||||
|
||||
void Run();
|
||||
void PostTask(TTask const & task);
|
||||
|
||||
private:
|
||||
std::queue<TTask> m_tasks;
|
||||
|
||||
ThreadChecker m_checker;
|
||||
};
|
||||
} // namespace storage
|
||||
Reference in New Issue
Block a user