Flutter Engine
flutter::EmbedderThreadHost Class Reference

#include <embedder_thread_host.h>

Public Member Functions

 EmbedderThreadHost (ThreadHost host, flutter::TaskRunners runners, std::set< fml::RefPtr< EmbedderTaskRunner >> embedder_task_runners)
 
 ~EmbedderThreadHost ()
 
bool IsValid () const
 
const flutter::TaskRunnersGetTaskRunners () const
 
bool PostTask (int64_t runner, uint64_t task) const
 

Static Public Member Functions

static std::unique_ptr< EmbedderThreadHostCreateEmbedderOrEngineManagedThreadHost (const FlutterCustomTaskRunners *custom_task_runners)
 

Detailed Description

Definition at line 20 of file embedder_thread_host.h.

Constructor & Destructor Documentation

◆ EmbedderThreadHost()

flutter::EmbedderThreadHost::EmbedderThreadHost ( ThreadHost  host,
flutter::TaskRunners  runners,
std::set< fml::RefPtr< EmbedderTaskRunner >>  embedder_task_runners 
)

Definition at line 245 of file embedder_thread_host.cc.

References ~EmbedderThreadHost().

249  : host_(std::move(host)), runners_(std::move(runners)) {
250  for (const auto& runner : embedder_task_runners) {
251  runners_map_[reinterpret_cast<int64_t>(runner.get())] = runner;
252  }
253 }

◆ ~EmbedderThreadHost()

flutter::EmbedderThreadHost::~EmbedderThreadHost ( )
default

Referenced by EmbedderThreadHost().

Member Function Documentation

◆ CreateEmbedderOrEngineManagedThreadHost()

std::unique_ptr< EmbedderThreadHost > flutter::EmbedderThreadHost::CreateEmbedderOrEngineManagedThreadHost ( const FlutterCustomTaskRunners custom_task_runners)
static

Definition at line 83 of file embedder_thread_host.cc.

Referenced by FlutterEngineInitialize().

84  {
85  {
86  auto host = CreateEmbedderManagedThreadHost(custom_task_runners);
87  if (host && host->IsValid()) {
88  return host;
89  }
90  }
91 
92  // Only attempt to create the engine managed host if the embedder did not
93  // specify a custom configuration. Don't fallback to the engine managed
94  // configuration if the embedder attempted to specify a configuration but
95  // messed up with an incorrect configuration.
96  if (custom_task_runners == nullptr) {
97  auto host = CreateEngineManagedThreadHost();
98  if (host && host->IsValid()) {
99  return host;
100  }
101  }
102 
103  return nullptr;
104 }

◆ GetTaskRunners()

const flutter::TaskRunners & flutter::EmbedderThreadHost::GetTaskRunners ( ) const

Definition at line 261 of file embedder_thread_host.cc.

261  {
262  return runners_;
263 }

◆ IsValid()

bool flutter::EmbedderThreadHost::IsValid ( ) const

Definition at line 257 of file embedder_thread_host.cc.

References flutter::TaskRunners::IsValid().

257  {
258  return runners_.IsValid();
259 }
bool IsValid() const
Definition: task_runners.cc:46

◆ PostTask()

bool flutter::EmbedderThreadHost::PostTask ( int64_t  runner,
uint64_t  task 
) const

Definition at line 265 of file embedder_thread_host.cc.

265  {
266  auto found = runners_map_.find(runner);
267  if (found == runners_map_.end()) {
268  return false;
269  }
270  return found->second->PostTask(task);
271 }

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