v8  7.4.288(node12.0.0)
V8 is Google's open source JavaScript engine
MicrotaskQueue Class Referenceabstract

#include <v8.h>

Public Member Functions

virtual ~MicrotaskQueue ()=default
virtual void EnqueueMicrotask (Isolate *isolate, Local< Function > microtask)=0
virtual void EnqueueMicrotask (v8::Isolate *isolate, MicrotaskCallback callback, void *data=nullptr)=0
virtual void AddMicrotasksCompletedCallback (MicrotasksCompletedCallbackWithData callback, void *data=nullptr)=0
virtual void RemoveMicrotasksCompletedCallback (MicrotasksCompletedCallbackWithData callback, void *data=nullptr)=0
virtual void PerformCheckpoint (Isolate *isolate)=0
virtual bool IsRunningMicrotasks () const =0

Static Public Member Functions

static std::unique_ptr< MicrotaskQueueNew ()


class internal::MicrotaskQueue

Detailed Description

Represents the microtask queue, where microtasks are stored and processed. https://html.spec.whatwg.org/multipage/webappapis.html#microtask-queue https://html.spec.whatwg.org/multipage/webappapis.html#enqueuejob(queuename,-job,-arguments) https://html.spec.whatwg.org/multipage/webappapis.html#perform-a-microtask-checkpoint

A MicrotaskQueue instance may be associated to multiple Contexts by passing it to Context::New(), and they can be detached by Context::DetachGlobal(). The embedder must keep the MicrotaskQueue instance alive until all associated Contexts are gone or detached.

Use the same instance of MicrotaskQueue for all Contexts that may access each other synchronously. E.g. for Web embedding, use the same instance for all origins that share the same URL scheme and eTLD+1.

Definition at line 6776 of file v8.h.

Constructor & Destructor Documentation

◆ ~MicrotaskQueue()

virtual ~MicrotaskQueue ( )

Member Function Documentation

◆ AddMicrotasksCompletedCallback()

virtual void AddMicrotasksCompletedCallback ( MicrotasksCompletedCallbackWithData  callback,
void *  data = nullptr 
pure virtual

Adds a callback to notify the embedder after microtasks were run. The callback is triggered by explicit RunMicrotasks call or automatic microtasks execution (see Isolate::SetMicrotasksPolicy).

Callback will trigger even if microtasks were attempted to run, but the microtasks queue was empty and no single microtask was actually executed.

Executing scripts inside the callback will not re-trigger microtasks and the callback.

◆ EnqueueMicrotask() [1/2]

virtual void EnqueueMicrotask ( Isolate isolate,
Local< Function microtask 
pure virtual

Enqueues the callback to the queue.

◆ EnqueueMicrotask() [2/2]

virtual void EnqueueMicrotask ( v8::Isolate isolate,
MicrotaskCallback  callback,
void *  data = nullptr 
pure virtual

Enqueues the callback to the queue.

◆ IsRunningMicrotasks()

virtual bool IsRunningMicrotasks ( ) const
pure virtual

Returns true if a microtask is running on this MicrotaskQueue instance.

◆ New()

static std::unique_ptr<MicrotaskQueue> New ( )

Creates an empty MicrotaskQueue instance.

◆ PerformCheckpoint()

virtual void PerformCheckpoint ( Isolate isolate)
pure virtual

Runs microtasks if no microtask is running on this MicrotaskQueue instance.

◆ RemoveMicrotasksCompletedCallback()

virtual void RemoveMicrotasksCompletedCallback ( MicrotasksCompletedCallbackWithData  callback,
void *  data = nullptr 
pure virtual

Removes callback that was installed by AddMicrotasksCompletedCallback.

Friends And Related Function Documentation

◆ internal::MicrotaskQueue

friend class internal::MicrotaskQueue

Definition at line 6830 of file v8.h.

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