class thread_checker
Defined at line 42 of file ../../sdk/lib/fit/include/lib/fit/thread_checker.h
A simple class that records the identity of the thread that it was created
on, and at later points can tell if the current thread is the same as its
creation thread. This class is thread-safe.
In addition to providing an explicit check of the current thread,
|thread_checker| complies with BasicLockable, checking the current thread
when |lock| is called. This allows static thread safety analysis to be used
to ensure that resources are accessed in a context that is checked (at debug
runtime) to ensure that it's running on the correct thread:
class MyClass {
public:
void Foo() {
std::lock_guard
<fit
::thread_checker> locker(thread_checker_);
resource_ = 0;
}
private:
fit::thread_checker thread_checker_;
int resource_ FIT_GUARDED(thread_checker_);
}
Note: |lock| checks the thread in debug builds only.
Public Methods
void thread_checker ()
Default constructor. Constructs a thread checker bound to the currently
running thread.
Defined at line 46 of file ../../sdk/lib/fit/include/lib/fit/thread_checker.h
void thread_checker (std::thread::id self)
Constructs a thread checker bound to an explicit other thread.
Defined at line 48 of file ../../sdk/lib/fit/include/lib/fit/thread_checker.h
void ~thread_checker ()
Defined at line 49 of file ../../sdk/lib/fit/include/lib/fit/thread_checker.h
bool is_thread_valid ()
Returns true if the current thread is the thread this object was created
on and false otherwise.
Defined at line 53 of file ../../sdk/lib/fit/include/lib/fit/thread_checker.h
void lock ()
Implementation of the BaseLockable requirement
Defined at line 56 of file ../../sdk/lib/fit/include/lib/fit/thread_checker.h
void unlock ()
Defined at line 58 of file ../../sdk/lib/fit/include/lib/fit/thread_checker.h