Flutter Engine
 
Loading...
Searching...
No Matches
tonic::DartMicrotaskQueue Class Reference

#include <dart_microtask_queue.h>

Public Member Functions

 DartMicrotaskQueue ()
 
 ~DartMicrotaskQueue ()
 
void ScheduleMicrotask (Dart_Handle callback)
 
void RunMicrotasks ()
 
void Destroy ()
 
bool HasMicrotasks () const
 
DartErrorHandleType GetLastError ()
 

Static Public Member Functions

static void StartForCurrentThread ()
 
static DartMicrotaskQueueGetForCurrentThread ()
 

Detailed Description

Definition at line 16 of file dart_microtask_queue.h.

Constructor & Destructor Documentation

◆ DartMicrotaskQueue()

tonic::DartMicrotaskQueue::DartMicrotaskQueue ( )

Definition at line 54 of file dart_microtask_queue.cc.

54: last_error_(kNoError) {}
@ kNoError
Definition dart_error.h:68

Referenced by StartForCurrentThread().

◆ ~DartMicrotaskQueue()

tonic::DartMicrotaskQueue::~DartMicrotaskQueue ( )
default

Member Function Documentation

◆ Destroy()

void tonic::DartMicrotaskQueue::Destroy ( )

Definition at line 97 of file dart_microtask_queue.cc.

97 {
99 SetQueue(nullptr);
100 delete this;
101}
static DartMicrotaskQueue * GetForCurrentThread()
#define TONIC_DCHECK
Definition macros.h:32

References GetForCurrentThread(), and TONIC_DCHECK.

◆ GetForCurrentThread()

DartMicrotaskQueue * tonic::DartMicrotaskQueue::GetForCurrentThread ( )
static

Definition at line 62 of file dart_microtask_queue.cc.

62 {
63 return GetQueue();
64}

Referenced by Destroy().

◆ GetLastError()

DartErrorHandleType tonic::DartMicrotaskQueue::GetLastError ( )

Definition at line 103 of file dart_microtask_queue.cc.

103 {
104 return last_error_;
105}

Referenced by flutter::UIDartState::GetLastError().

◆ HasMicrotasks()

bool tonic::DartMicrotaskQueue::HasMicrotasks ( ) const
inline

Definition at line 29 of file dart_microtask_queue.h.

29{ return !queue_.empty(); }

Referenced by flutter::UIDartState::HasPendingMicrotasks().

◆ RunMicrotasks()

void tonic::DartMicrotaskQueue::RunMicrotasks ( )

Definition at line 70 of file dart_microtask_queue.cc.

70 {
71 while (!queue_.empty()) {
72 MicrotaskQueue local;
73 std::swap(queue_, local);
74 for (const auto& callback : local) {
75 if (auto dart_state = callback.dart_state().lock()) {
76 DartState::Scope dart_scope(dart_state.get());
77 Dart_Handle result = Dart_InvokeClosure(callback.value(), 0, nullptr);
78 // If the Dart program has set a return code, then it is intending to
79 // shut down by way of a fatal error, and so there is no need to emit a
80 // log message.
81 if (!dart_state->has_set_return_code() || !Dart_IsError(result) ||
82 !Dart_IsFatalError(result)) {
83 CheckAndHandleError(result);
84 }
86 if (error != kNoError) {
87 last_error_ = error;
88 }
89 dart_state->MessageEpilogue(result);
90 if (!Dart_CurrentIsolate())
91 return;
92 }
93 }
94 }
95}
const uint8_t uint32_t uint32_t GError ** error
FlutterDesktopBinaryReply callback
DartErrorHandleType GetErrorHandleType(Dart_Handle handle)
Definition dart_error.cc:56
DartErrorHandleType
Definition dart_error.h:67
bool CheckAndHandleError(Dart_Handle handle)
Definition dart_error.cc:33

References callback, tonic::CheckAndHandleError(), error, tonic::GetErrorHandleType(), and tonic::kNoError.

Referenced by flutter::UIDartState::FlushMicrotasksNow().

◆ ScheduleMicrotask()

void tonic::DartMicrotaskQueue::ScheduleMicrotask ( Dart_Handle  callback)

Definition at line 66 of file dart_microtask_queue.cc.

66 {
67 queue_.emplace_back(DartState::Current(), callback);
68}
static DartState * Current()
Definition dart_state.cc:56

References callback, and tonic::DartState::Current().

Referenced by flutter::UIDartState::ScheduleMicrotask().

◆ StartForCurrentThread()

void tonic::DartMicrotaskQueue::StartForCurrentThread ( )
static

Definition at line 58 of file dart_microtask_queue.cc.

58 {
59 SetQueue(new DartMicrotaskQueue());
60}

References DartMicrotaskQueue().


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