|
Chromium Embedded Framework (CEF)
122.0.1+gf3f83ff+chromium-122.0.6261.6
|
ThreadChecker is a helper class used to help verify that some methods of a class are called from the same thread. More...
#include "include/base/cef_thread_checker.h"
Additional Inherited Members | |
Public Member Functions inherited from base::cef_internal::ThreadCheckerDoNothing | |
| bool | CalledOnValidThread () const |
| void | DetachFromThread () |
ThreadChecker is a helper class used to help verify that some methods of a class are called from the same thread.
It provides identical functionality to base::NonThreadSafe, but it is meant to be held as a member variable, rather than inherited from base::NonThreadSafe.
While inheriting from base::NonThreadSafe may give a clear indication about the thread-safety of a class, it may also lead to violations of the style guide with regard to multiple inheritance. The choice between having a ThreadChecker member and inheriting from base::NonThreadSafe should be based on whether:
If neither of these are true, then having a ThreadChecker member and calling CalledOnValidThread is the preferable solution.
Example:
class MyClass {
public:
void Foo() {
DCHECK(thread_checker_.CalledOnValidThread());
... (do stuff) ...
}
private:
ThreadChecker thread_checker_;
}
In Release mode, CalledOnValidThread will always return true.