Flutter Engine
fml::MessageLoop Class Reference

#include <message_loop.h>

Public Member Functions

bool IsValid () const
 
void Run ()
 
void Terminate ()
 
void AddTaskObserver (intptr_t key, const fml::closure &callback)
 
void RemoveTaskObserver (intptr_t key)
 
fml::RefPtr< fml::TaskRunnerGetTaskRunner () const
 
void RunExpiredTasksNow ()
 
 ~MessageLoop ()
 

Static Public Member Functions

static FML_EMBEDDER_ONLY MessageLoopGetCurrent ()
 
static void EnsureInitializedForCurrentThread ()
 
static bool IsInitializedForCurrentThread ()
 
static TaskQueueId GetCurrentTaskQueueId ()
 

Friends

class TaskRunner
 
class MessageLoopImpl
 

Detailed Description

Definition at line 16 of file message_loop.h.

Constructor & Destructor Documentation

◆ ~MessageLoop()

fml::MessageLoop::~MessageLoop ( )
default

Member Function Documentation

◆ AddTaskObserver()

void fml::MessageLoop::AddTaskObserver ( intptr_t  key,
const fml::closure callback 
)

◆ EnsureInitializedForCurrentThread()

◆ GetCurrent()

◆ GetCurrentTaskQueueId()

TaskQueueId fml::MessageLoop::GetCurrentTaskQueueId ( )
static

Definition at line 76 of file message_loop.cc.

References FML_CHECK.

Referenced by flutter::testing::GetThreadMergerFromPlatformThread(), flutter::testing::GetThreadMergerFromRasterThread(), fml::RasterThreadMerger::IsOnPlatformThread(), fml::TaskRunnerChecker::RunsOnCreationTaskRunner(), fml::TaskRunnerChecker::RunsOnTheSameThread(), fml::TaskRunner::RunsTasksOnCurrentThread(), fml::testing::TEST(), and flutter::testing::TestSkObject::~TestSkObject().

76  {
77  auto* loop = tls_message_loop.get();
78  FML_CHECK(loop != nullptr)
79  << "MessageLoop::EnsureInitializedForCurrentThread was not called on "
80  "this thread prior to message loop use.";
81  return loop->GetLoopImpl()->GetTaskQueueId();
82 }
FML_THREAD_LOCAL ThreadLocalUniquePtr< MessageLoop > tls_message_loop
Definition: message_loop.cc:17
#define FML_CHECK(condition)
Definition: logging.h:68

◆ GetTaskRunner()

◆ IsInitializedForCurrentThread()

bool fml::MessageLoop::IsInitializedForCurrentThread ( )
static

Definition at line 35 of file message_loop.cc.

References fml::MessageLoopImpl::Create(), FML_CHECK, and ~MessageLoop().

Referenced by fml::TaskRunnerChecker::RunsOnCreationTaskRunner(), and fml::TaskRunner::RunsTasksOnCurrentThread().

35  {
36  return tls_message_loop.get() != nullptr;
37 }
FML_THREAD_LOCAL ThreadLocalUniquePtr< MessageLoop > tls_message_loop
Definition: message_loop.cc:17

◆ IsValid()

bool fml::MessageLoop::IsValid ( ) const

◆ RemoveTaskObserver()

void fml::MessageLoop::RemoveTaskObserver ( intptr_t  key)

◆ Run()

void fml::MessageLoop::Run ( )

Definition at line 48 of file message_loop.cc.

Referenced by flutter::RunTester(), and fml::testing::TEST().

48  {
49  loop_->DoRun();
50 }

◆ RunExpiredTasksNow()

void fml::MessageLoop::RunExpiredTasksNow ( )

Definition at line 72 of file message_loop.cc.

Referenced by __FlutterEngineFlushPendingTasksNow(), and flutter::testing::TEST_F().

72  {
73  loop_->RunExpiredTasksNow();
74 }

◆ Terminate()

void fml::MessageLoop::Terminate ( )

Definition at line 52 of file message_loop.cc.

Referenced by flutter::ScriptCompletionTaskObserver::DidProcessTask(), fml::Thread::Join(), TEST(), and fml::testing::TEST().

52  {
53  loop_->DoTerminate();
54 }

Friends And Related Function Documentation

◆ MessageLoopImpl

friend class MessageLoopImpl
friend

Definition at line 47 of file message_loop.h.

◆ TaskRunner

friend class TaskRunner
friend

Definition at line 46 of file message_loop.h.


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