C/C++ API Reference
Loading...
Searching...
No Matches
pw::LazyInitThreadChecker Class Reference

Overview

A BaseLockable class that works like ThreadChecker but only initializes its thread id when first locked instead of construction time.

This is useful for cases where you may not have access to right thread id at construction time, but still want to assert fields are always accessed on the same thread.

Note, this class shouldn't be locked outside of a normal thread context. It's not valid to use it interrupt context or before the scheduler is started.

class MyClass {
public:
void Foo() {
std::lock_guard checker(thread_checker_);
resource_ = 0;
}
private:
pw::LazyInitThreadChecker thread_checker_;
int resource_ PW_GUARDED_BY(thread_checker_);
};
Definition: checker.h:98
#define PW_GUARDED_BY(x)
Definition: lock_annotations.h:60

Public Member Functions

void lock ()
 
void unlock ()
 

The documentation for this class was generated from the following file: