mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-07 13:03:54 +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
base/thread_checker.hpp
Normal file
32
base/thread_checker.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include "base/assert.hpp"
|
||||
#include "base/macros.hpp"
|
||||
|
||||
#include <thread>
|
||||
|
||||
/// This class remembers id of a thread on which it was created, and
|
||||
/// then can be used to verify that CalledOnOriginalThread() is called
|
||||
/// from a thread on which it was created.
|
||||
class ThreadChecker
|
||||
{
|
||||
public:
|
||||
ThreadChecker();
|
||||
|
||||
/// \return True if this method is called from a thread on which
|
||||
/// current ThreadChecker's instance was created, false otherwise.
|
||||
bool CalledOnOriginalThread() const;
|
||||
|
||||
private:
|
||||
std::thread::id const m_id;
|
||||
|
||||
DISALLOW_COPY_AND_MOVE(ThreadChecker);
|
||||
};
|
||||
|
||||
#define DECLARE_THREAD_CHECKER(threadCheckerName) ThreadChecker threadCheckerName
|
||||
#define CHECK_THREAD_CHECKER(threadCheckerName, msg) CHECK(threadCheckerName.CalledOnOriginalThread(), msg)
|
||||
#define DECLARE_AND_CHECK_THREAD_CHECKER(msg) \
|
||||
{ \
|
||||
static const ThreadChecker threadChecker; \
|
||||
CHECK(threadChecker.CalledOnOriginalThread(), (msg)); \
|
||||
}
|
||||
Reference in New Issue
Block a user