Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
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

◆ ~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

◆ GetForCurrentThread()

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

Definition at line 62 of file dart_microtask_queue.cc.

62 {
63 return GetQueue();
64}

◆ GetLastError()

DartErrorHandleType tonic::DartMicrotaskQueue::GetLastError ( )

Definition at line 103 of file dart_microtask_queue.cc.

103 {
104 return last_error_;
105}

◆ HasMicrotasks()

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

Definition at line 29 of file dart_microtask_queue.h.

29{ return !queue_.empty(); }

◆ 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) ||
84 }
86 if (error != kNoError) {
87 last_error_ = error;
88 }
89 dart_state->MessageEpilogue(result);
91 return;
92 }
93 }
94 }
95}
struct _Dart_Handle * Dart_Handle
Definition dart_api.h:258
DART_EXPORT bool Dart_IsFatalError(Dart_Handle handle)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_InvokeClosure(Dart_Handle closure, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT Dart_Isolate Dart_CurrentIsolate(void)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
const uint8_t uint32_t uint32_t GError ** error
GAsyncResult * result
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

◆ 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

◆ StartForCurrentThread()

void tonic::DartMicrotaskQueue::StartForCurrentThread ( )
static

Definition at line 58 of file dart_microtask_queue.cc.

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

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