Pigweed
C/C++ API Reference
|
Public Member Functions | |
ThreadChecker (Thread::id id) | |
void | lock () |
void | unlock () |
A BaseLockable class that stores the id of a thread and verifies that all lock()
calls happen on that thread if PW_THREAD_CHECKER_RUNTIME_ASSERT_ENABLED
config is set.
Its purpose is to provide a check that data that is meant to only be accessed from a single thread is always accessed from that thread. This is useful on data that isn't synchronized using regular sync primitives. For example, this could be used on data that is always used on an async dispatcher to ensure all data access happens on that dispatcher thread.
In addition to providing an optional runtime check, this class can be used with static thread safety analysis to ensure that resources are accessed in a context that is checked.