Flutter Engine
fml::ThreadChecker Class Referencefinal

#include <thread_checker.h>

Public Member Functions

 ThreadChecker ()
 
 ~ThreadChecker ()
 
bool IsCreationThreadCurrent () const
 

Detailed Description

Definition at line 31 of file thread_checker.h.

Constructor & Destructor Documentation

◆ ThreadChecker()

fml::ThreadChecker::ThreadChecker ( )
inline

Definition at line 43 of file thread_checker.h.

43 : self_(pthread_self()) {}

◆ ~ThreadChecker()

fml::ThreadChecker::~ThreadChecker ( )
inline

Definition at line 44 of file thread_checker.h.

44 {}

Member Function Documentation

◆ IsCreationThreadCurrent()

bool fml::ThreadChecker::IsCreationThreadCurrent ( ) const
inline

Definition at line 48 of file thread_checker.h.

References FML_DLOG.

48  {
49  pthread_t current_thread = pthread_self();
50  bool is_creation_thread_current = !!pthread_equal(current_thread, self_);
51 #ifdef __APPLE__
52  // TODO(https://github.com/flutter/flutter/issues/45272): Implement for
53  // other platforms.
54  if (!is_creation_thread_current) {
55  static const int buffer_length = 128;
56  char expected_thread[buffer_length];
57  char actual_thread[buffer_length];
58  if (0 == pthread_getname_np(current_thread, actual_thread,
59  buffer_length) &&
60  0 == pthread_getname_np(self_, actual_thread, buffer_length)) {
61  FML_DLOG(ERROR) << "IsCreationThreadCurrent expected thread: '"
62  << expected_thread << "' actual thread:'"
63  << actual_thread << "'";
64  }
65  }
66 #endif // __APPLE__
67  return is_creation_thread_current;
68  }
#define FML_DLOG(severity)
Definition: logging.h:85

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