v8 12.4.254 (node 22.4.1)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
TaskRunner Class Referenceabstract

#include <v8-platform.h>

Public Member Functions

virtual void PostTask (std::unique_ptr< Task > task)
 
virtual void PostNonNestableTask (std::unique_ptr< Task > task)
 
virtual void PostDelayedTask (std::unique_ptr< Task > task, double delay_in_seconds)
 
virtual void PostNonNestableDelayedTask (std::unique_ptr< Task > task, double delay_in_seconds)
 
virtual void PostIdleTask (std::unique_ptr< IdleTask > task)
 
virtual bool IdleTasksEnabled ()=0
 
virtual bool NonNestableTasksEnabled () const
 
virtual bool NonNestableDelayedTasksEnabled () const
 
 TaskRunner ()=default
 
virtual ~TaskRunner ()=default
 
 TaskRunner (const TaskRunner &)=delete
 
TaskRunneroperator= (const TaskRunner &)=delete
 

Protected Member Functions

virtual void PostTaskImpl (std::unique_ptr< Task > task, const SourceLocation &location)
 
virtual void PostNonNestableTaskImpl (std::unique_ptr< Task > task, const SourceLocation &location)
 
virtual void PostDelayedTaskImpl (std::unique_ptr< Task > task, double delay_in_seconds, const SourceLocation &location)
 
virtual void PostNonNestableDelayedTaskImpl (std::unique_ptr< Task > task, double delay_in_seconds, const SourceLocation &location)
 
virtual void PostIdleTaskImpl (std::unique_ptr< IdleTask > task, const SourceLocation &location)
 

Detailed Description

A TaskRunner allows scheduling of tasks. The TaskRunner may still be used to post tasks after the isolate gets destructed, but these tasks may not get executed anymore. All tasks posted to a given TaskRunner will be invoked in sequence. Tasks can be posted from any thread.

Definition at line 74 of file v8-platform.h.

Constructor & Destructor Documentation

◆ TaskRunner() [1/2]

TaskRunner ( )
default

◆ ~TaskRunner()

virtual ~TaskRunner ( )
virtualdefault

◆ TaskRunner() [2/2]

TaskRunner ( const TaskRunner )
delete

Member Function Documentation

◆ IdleTasksEnabled()

virtual bool IdleTasksEnabled ( )
pure virtual

Returns true if idle tasks are enabled for this TaskRunner.

◆ NonNestableDelayedTasksEnabled()

virtual bool NonNestableDelayedTasksEnabled ( ) const
inlinevirtual

Returns true if non-nestable delayed tasks are enabled for this TaskRunner.

Definition at line 171 of file v8-platform.h.

◆ NonNestableTasksEnabled()

virtual bool NonNestableTasksEnabled ( ) const
inlinevirtual

Returns true if non-nestable tasks are enabled for this TaskRunner.

Definition at line 166 of file v8-platform.h.

◆ operator=()

TaskRunner & operator= ( const TaskRunner )
delete

◆ PostDelayedTask()

virtual void PostDelayedTask ( std::unique_ptr< Task task,
double  delay_in_seconds 
)
inlinevirtual

Schedules a task to be invoked by this TaskRunner. The task is scheduled after the given number of seconds |delay_in_seconds|. The TaskRunner implementation takes ownership of |task|.

Embedders should override PostDelayedTaskImpl instead of this.

Definition at line 114 of file v8-platform.h.

References SourceLocation::Current(), and TaskRunner::PostDelayedTaskImpl().

◆ PostDelayedTaskImpl()

virtual void PostDelayedTaskImpl ( std::unique_ptr< Task task,
double  delay_in_seconds,
const SourceLocation location 
)
inlineprotectedvirtual

Definition at line 187 of file v8-platform.h.

Referenced by TaskRunner::PostDelayedTask().

◆ PostIdleTask()

virtual void PostIdleTask ( std::unique_ptr< IdleTask task)
inlinevirtual

Schedules an idle task to be invoked by this TaskRunner. The task is scheduled when the embedder is idle. Requires that |TaskRunnerIdleTasksEnabled()| is true. Idle tasks may be reordered relative to other task types and may be starved for an arbitrarily long time if no idle time is available. The TaskRunner implementation takes ownership of |task|.

Embedders should override PostIdleTaskImpl instead of this.

Definition at line 154 of file v8-platform.h.

References SourceLocation::Current(), and TaskRunner::PostIdleTaskImpl().

◆ PostIdleTaskImpl()

virtual void PostIdleTaskImpl ( std::unique_ptr< IdleTask task,
const SourceLocation location 
)
inlineprotectedvirtual

Definition at line 193 of file v8-platform.h.

Referenced by TaskRunner::PostIdleTask().

◆ PostNonNestableDelayedTask()

virtual void PostNonNestableDelayedTask ( std::unique_ptr< Task task,
double  delay_in_seconds 
)
inlinevirtual

Schedules a task to be invoked by this TaskRunner. The task is scheduled after the given number of seconds |delay_in_seconds|. The TaskRunner implementation takes ownership of |task|. The |task| cannot be nested within other task executions.

Tasks which shouldn't be interleaved with JS execution must be posted with |PostNonNestableTask| or |PostNonNestableDelayedTask|. This is because the embedder may process tasks in a callback which is called during JS execution.

In particular, tasks which execute JS must be non-nestable, since JS execution is not allowed to nest.

Requires that |TaskRunnerNonNestableDelayedTasksEnabled()| is true.

Embedders should override PostNonNestableDelayedTaskImpl instead of this.

Definition at line 138 of file v8-platform.h.

References SourceLocation::Current(), and TaskRunner::PostNonNestableDelayedTaskImpl().

◆ PostNonNestableDelayedTaskImpl()

virtual void PostNonNestableDelayedTaskImpl ( std::unique_ptr< Task task,
double  delay_in_seconds,
const SourceLocation location 
)
inlineprotectedvirtual

Definition at line 190 of file v8-platform.h.

Referenced by TaskRunner::PostNonNestableDelayedTask().

◆ PostNonNestableTask()

virtual void PostNonNestableTask ( std::unique_ptr< Task task)
inlinevirtual

Schedules a task to be invoked by this TaskRunner. The TaskRunner implementation takes ownership of |task|. The |task| cannot be nested within other task executions.

Tasks which shouldn't be interleaved with JS execution must be posted with |PostNonNestableTask| or |PostNonNestableDelayedTask|. This is because the embedder may process tasks in a callback which is called during JS execution.

In particular, tasks which execute JS must be non-nestable, since JS execution is not allowed to nest.

Requires that |TaskRunnerNonNestableTasksEnabled()| is true.

Embedders should override PostNonNestableTaskImpl instead of this.

Definition at line 103 of file v8-platform.h.

References SourceLocation::Current(), and TaskRunner::PostNonNestableTaskImpl().

◆ PostNonNestableTaskImpl()

virtual void PostNonNestableTaskImpl ( std::unique_ptr< Task task,
const SourceLocation location 
)
inlineprotectedvirtual

Definition at line 185 of file v8-platform.h.

Referenced by TaskRunner::PostNonNestableTask().

◆ PostTask()

virtual void PostTask ( std::unique_ptr< Task task)
inlinevirtual

Schedules a task to be invoked by this TaskRunner. The TaskRunner implementation takes ownership of |task|.

Embedders should override PostTaskImpl instead of this.

Definition at line 82 of file v8-platform.h.

References SourceLocation::Current(), and TaskRunner::PostTaskImpl().

◆ PostTaskImpl()

virtual void PostTaskImpl ( std::unique_ptr< Task task,
const SourceLocation location 
)
inlineprotectedvirtual

Implementation of above methods with an additional location argument.

Definition at line 183 of file v8-platform.h.

Referenced by TaskRunner::PostTask().


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