Flutter Engine
fml::TaskRunner Class Reference

#include <task_runner.h>

Inheritance diagram for fml::TaskRunner:
fml::RefCountedThreadSafe< TaskRunner > fml::internal::RefCountedThreadSafeBase flutter::EmbedderTaskRunner flutter_runner::CompatTaskRunner

Public Member Functions

virtual ~TaskRunner ()
 
virtual void PostTask (const fml::closure &task)
 
virtual void PostTaskForTime (const fml::closure &task, fml::TimePoint target_time)
 
virtual void PostDelayedTask (const fml::closure &task, fml::TimeDelta delay)
 
virtual bool RunsTasksOnCurrentThread ()
 
virtual TaskQueueId GetTaskQueueId ()
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< TaskRunner >
void Release () const
 
- Public Member Functions inherited from fml::internal::RefCountedThreadSafeBase
void AddRef () const
 
bool HasOneRef () const
 
void AssertHasOneRef () const
 

Static Public Member Functions

static void RunNowOrPostTask (fml::RefPtr< fml::TaskRunner > runner, const fml::closure &task)
 

Protected Member Functions

 TaskRunner (fml::RefPtr< MessageLoopImpl > loop)
 
- Protected Member Functions inherited from fml::RefCountedThreadSafe< TaskRunner >
 RefCountedThreadSafe ()
 
 ~RefCountedThreadSafe ()
 
- Protected Member Functions inherited from fml::internal::RefCountedThreadSafeBase
 RefCountedThreadSafeBase ()
 
 ~RefCountedThreadSafeBase ()
 
bool Release () const
 
void Adopt ()
 

Detailed Description

Definition at line 19 of file task_runner.h.

Constructor & Destructor Documentation

◆ ~TaskRunner()

fml::TaskRunner::~TaskRunner ( )
virtualdefault

Referenced by TaskRunner().

◆ TaskRunner()

fml::TaskRunner::TaskRunner ( fml::RefPtr< MessageLoopImpl loop)
protected

Definition at line 19 of file task_runner.cc.

References ~TaskRunner().

20  : loop_(std::move(loop)) {}

Member Function Documentation

◆ GetTaskQueueId()

TaskQueueId fml::TaskRunner::GetTaskQueueId ( )
virtual

Definition at line 38 of file task_runner.cc.

References FML_DCHECK.

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

38  {
39  FML_DCHECK(loop_);
40  return loop_->GetTaskQueueId();
41 }
#define FML_DCHECK(condition)
Definition: logging.h:86

◆ PostDelayedTask()

void fml::TaskRunner::PostDelayedTask ( const fml::closure task,
fml::TimeDelta  delay 
)
virtual

◆ PostTask()

void fml::TaskRunner::PostTask ( const fml::closure task)
virtual

Reimplemented in flutter_runner::CompatTaskRunner.

Definition at line 24 of file task_runner.cc.

References fml::TimePoint::Now().

Referenced by flutter::AndroidShellHolder::AndroidShellHolder(), flutter::PlatformMessageResponseDart::Complete(), flutter::PlatformMessageResponseDarwin::Complete(), flutter::PlatformMessageResponseDart::CompleteEmpty(), flutter::PlatformMessageResponseDarwin::CompleteEmpty(), flutter::CopyToBitmap(), flutter::testing::ShellTest::DispatchPointerData(), flutter::Rasterizer::Draw(), flutter::EmbedderPlatformMessageResponse::EmbedderPlatformMessageResponse(), flutter::EncodeImage(), flutter_runner::Engine::Engine(), flutter::Shell::GetDartVM(), flutter::DartIsolate::GetMessageHandlingTaskRunner(), flutter::MultiFrameCodec::getNextFrame(), flutter::FlutterMain::GetSettings(), flutter::testing::GetTestNameFromTestInfo(), fml::Thread::Join(), flutter::testing::ShellTest::NotifyIdle(), flutter::Shell::NotifyLowMemoryWarning(), flutter::PersistentCacheStore(), flutter_runner::PlatformView::PlatformView(), flutter::PrepareKernelMappings(), flutter::testing::ShellTest::PumpOneFrame(), flutter::PersistentCache::Purge(), flutter::Animator::RequestFrame(), RunNowOrPostTask(), flutter::testing::ShellTest::SetViewportMetrics(), flutter::SamplingProfiler::Start(), TEST(), fml::testing::TEST(), flutter::testing::TEST_F(), flutter::testing::TestSimulatedInputEvents(), flutter::ViewHolder::UpdateScene(), flutter::testing::ShellTest::VSyncFlush(), flutter::VsyncWaiterAndroid::VsyncWaiterAndroid(), flutter::testing::WaitForIO(), flutter::PlatformMessageResponseDart::~PlatformMessageResponseDart(), and flutter::testing::TestTimeoutListener::~TestTimeoutListener().

24  {
25  loop_->PostTask(task, fml::TimePoint::Now());
26 }
static TimePoint Now()
Definition: time_point.cc:26

◆ PostTaskForTime()

void fml::TaskRunner::PostTaskForTime ( const fml::closure task,
fml::TimePoint  target_time 
)
virtual

Reimplemented in flutter_runner::CompatTaskRunner.

Definition at line 28 of file task_runner.cc.

Referenced by flutter::testing::EmbedderTestTaskRunner::EmbedderTestTaskRunner(), and flutter::VsyncWaiter::FireCallback().

29  {
30  loop_->PostTask(task, target_time);
31 }

◆ RunNowOrPostTask()

void fml::TaskRunner::RunNowOrPostTask ( fml::RefPtr< fml::TaskRunner runner,
const fml::closure task 
)
static

Definition at line 55 of file task_runner.cc.

References FML_DCHECK, PostTask(), and RunsTasksOnCurrentThread().

Referenced by flutter::Shell::Create(), flutter::testing::ShellTest::DestroyShell(), flutter::ScriptCompletionTaskObserver::DidProcessTask(), flutter::Animator::EnqueueTraceFlowId(), flutter::Shell::GetDartVM(), flutter_runner::Engine::GetEngineReturnCode(), flutter::testing::GetRasterizerResourceCacheBytesSync(), flutter::HandleMessageOnHandler(), flutter::Shell::IsSetup(), flutter::PlatformViewAndroid::NotifyChanged(), flutter::PlatformViewAndroid::NotifyCreated(), flutter::PlatformView::NotifyCreated(), flutter::PlatformViewAndroid::NotifyDestroyed(), flutter::PlatformViewAndroid::NotifySurfaceWindowChanged(), flutter::testing::ShellTest::OnServiceProtocol(), flutter::testing::ShellTest::PlatformViewNotifyCreated(), flutter::testing::ShellTest::PlatformViewNotifyDestroyed(), flutter::testing::RasterizerHasLayerTree(), flutter::Picture::RasterizeToImage(), flutter::testing::ShellTest::RestartEngine(), flutter::testing::RunDartCodeInIsolate(), flutter::testing::ShellTest::RunEngine(), flutter::Shell::RunEngine(), flutter::testing::AutoIsolateShutdown::RunInIsolateScope(), flutter::RunTester(), flutter::Shell::Screenshot(), flutter::testing::ShellTest::SendEnginePlatformMessage(), flutter::StartupAndShutdownShell(), flutter::testing::TEST_F(), flutter::testing::ValidateShell(), flutter::testing::ShellTest::VSyncFlush(), flutter_runner::VsyncWaiter::VsyncWaiter(), flutter::testing::AutoIsolateShutdown::~AutoIsolateShutdown(), flutter::Shell::~Shell(), flutter::testing::TestIOManager::~TestIOManager(), and flutter_runner::VsyncWaiter::~VsyncWaiter().

56  {
57  FML_DCHECK(runner);
58  if (runner->RunsTasksOnCurrentThread()) {
59  task();
60  } else {
61  runner->PostTask(std::move(task));
62  }
63 }
#define FML_DCHECK(condition)
Definition: logging.h:86
virtual void PostTask(const fml::closure &task)
Definition: task_runner.cc:24
virtual bool RunsTasksOnCurrentThread()
Definition: task_runner.cc:43

◆ RunsTasksOnCurrentThread()

bool fml::TaskRunner::RunsTasksOnCurrentThread ( )
virtual

Reimplemented in flutter_runner::CompatTaskRunner.

Definition at line 43 of file task_runner.cc.

References fml::MessageLoop::GetCurrentTaskQueueId(), fml::MessageLoop::IsInitializedForCurrentThread(), and fml::TaskRunnerChecker::RunsOnTheSameThread().

Referenced by flutter::Shell::Create(), flutter::ImageDecoder::Decode(), flutter::Rasterizer::Draw(), flutter::testing::EmbedderTestTaskRunner::EmbedderTestTaskRunner(), flutter::Shell::EngineHasLivePorts(), flutter::Shell::GetDartVM(), flutter::Shell::GetMainDisplayRefreshRate(), flutter::Shell::GetUIIsolateLastError(), flutter::ImageDecoder::ImageDecoder(), flutter::PlatformViewIOS::RegisterExternalTexture(), flutter::Shell::ReloadSystemFonts(), flutter::testing::RunDartCodeInIsolateOnUITaskRunner(), flutter::Shell::RunEngine(), RunNowOrPostTask(), flutter::VsyncWaiter::ScheduleSecondaryCallback(), flutter::ServiceProtocolFailureError(), flutter::PlatformViewIOS::SetOwnerViewController(), flutter_runner::VsyncWaiter::SnapToNextPhase(), TEST(), flutter::testing::TEST_F(), flutter::testing::TestIOManager::TestIOManager(), and flutter::Shell::WaitForFirstFrame().

43  {
45  return false;
46  }
47 
48  const auto current_queue_id = MessageLoop::GetCurrentTaskQueueId();
49  const auto loop_queue_id = loop_->GetTaskQueueId();
50 
51  return TaskRunnerChecker::RunsOnTheSameThread(current_queue_id,
52  loop_queue_id);
53 }
static TaskQueueId GetCurrentTaskQueueId()
Definition: message_loop.cc:76
static bool IsInitializedForCurrentThread()
Definition: message_loop.cc:35
static bool RunsOnTheSameThread(TaskQueueId queue_a, TaskQueueId queue_b)

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