diff options
author | Yuri Gorshenin <y@maps.me> | 2015-03-03 19:50:23 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:38:01 +0300 |
commit | 0f5fd548393e61f65691689965b77395d20cbe5e (patch) | |
tree | 852b0b762e74337b68c4295cd9c0bd19821ea647 /base/thread_checker.hpp | |
parent | c7bc79c347b3bf4c91a5fd0d7ddf3fdca082a5f0 (diff) |
Added ThreadChecker. Fixed dtor of WorkerThread.
Diffstat (limited to 'base/thread_checker.hpp')
-rw-r--r-- | base/thread_checker.hpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/base/thread_checker.hpp b/base/thread_checker.hpp new file mode 100644 index 0000000000..f9d80ce624 --- /dev/null +++ b/base/thread_checker.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include "macros.hpp" + +#include "../std/thread.hpp" + +/// 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: + thread::id const m_id; + + DISALLOW_COPY_AND_MOVE(ThreadChecker); +}; |