V8 Project
default-platform.h
Go to the documentation of this file.
1
// Copyright 2013 the V8 project authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef V8_LIBPLATFORM_DEFAULT_PLATFORM_H_
6
#define V8_LIBPLATFORM_DEFAULT_PLATFORM_H_
7
8
#include <map>
9
#include <queue>
10
#include <vector>
11
12
#include "
include/v8-platform.h
"
13
#include "
src/base/macros.h
"
14
#include "
src/base/platform/mutex.h
"
15
#include "
src/libplatform/task-queue.h
"
16
17
namespace
v8
{
18
namespace
platform {
19
20
class
TaskQueue;
21
class
Thread;
22
class
WorkerThread;
23
24
class
DefaultPlatform
:
public
Platform
{
25
public
:
26
DefaultPlatform
();
27
virtual
~DefaultPlatform
();
28
29
void
SetThreadPoolSize
(
int
thread_pool_size);
30
31
void
EnsureInitialized
();
32
33
bool
PumpMessageLoop
(
v8::Isolate
* isolate);
34
35
// v8::Platform implementation.
36
virtual
void
CallOnBackgroundThread
(
37
Task
* task,
ExpectedRuntime
expected_runtime)
OVERRIDE
;
38
virtual
void
CallOnForegroundThread
(
v8::Isolate
* isolate,
39
Task
* task)
OVERRIDE
;
40
41
private
:
42
static
const
int
kMaxThreadPoolSize
;
43
44
base::Mutex
lock_
;
45
bool
initialized_
;
46
int
thread_pool_size_
;
47
std::vector<WorkerThread*>
thread_pool_
;
48
TaskQueue
queue_
;
49
std::map<v8::Isolate*, std::queue<Task*> >
main_thread_queue_
;
50
51
DISALLOW_COPY_AND_ASSIGN
(
DefaultPlatform
);
52
};
53
54
55
} }
// namespace v8::platform
56
57
58
#endif
// V8_LIBPLATFORM_DEFAULT_PLATFORM_H_
v8::Isolate
Isolate represents an isolated instance of the V8 engine.
Definition:
v8.h:4356
v8::Platform
V8 Platform abstraction layer.
Definition:
v8-platform.h:28
v8::Platform::ExpectedRuntime
ExpectedRuntime
This enum is used to indicate whether a task is potentially long running, or causes a long wait.
Definition:
v8-platform.h:35
v8::Task
A Task represents a unit of work.
Definition:
v8-platform.h:15
v8::platform::DefaultPlatform
Definition:
default-platform.h:24
v8::platform::DefaultPlatform::thread_pool_
std::vector< WorkerThread * > thread_pool_
Definition:
default-platform.h:47
v8::platform::DefaultPlatform::main_thread_queue_
std::map< v8::Isolate *, std::queue< Task * > > main_thread_queue_
Definition:
default-platform.h:49
v8::platform::DefaultPlatform::lock_
base::Mutex lock_
Definition:
default-platform.h:44
v8::platform::DefaultPlatform::queue_
TaskQueue queue_
Definition:
default-platform.h:48
v8::platform::DefaultPlatform::CallOnBackgroundThread
virtual void CallOnBackgroundThread(Task *task, ExpectedRuntime expected_runtime) OVERRIDE
Schedules a task to be invoked on a background thread.
Definition:
default-platform.cc:97
v8::platform::DefaultPlatform::EnsureInitialized
void EnsureInitialized()
Definition:
default-platform.cc:70
v8::platform::DefaultPlatform::~DefaultPlatform
virtual ~DefaultPlatform()
Definition:
default-platform.cc:39
v8::platform::DefaultPlatform::SetThreadPoolSize
void SetThreadPoolSize(int thread_pool_size)
Definition:
default-platform.cc:59
v8::platform::DefaultPlatform::PumpMessageLoop
bool PumpMessageLoop(v8::Isolate *isolate)
Definition:
default-platform.cc:80
v8::platform::DefaultPlatform::DISALLOW_COPY_AND_ASSIGN
DISALLOW_COPY_AND_ASSIGN(DefaultPlatform)
v8::platform::DefaultPlatform::DefaultPlatform
DefaultPlatform()
Definition:
default-platform.cc:35
v8::platform::DefaultPlatform::initialized_
bool initialized_
Definition:
default-platform.h:45
v8::platform::DefaultPlatform::CallOnForegroundThread
virtual void CallOnForegroundThread(v8::Isolate *isolate, Task *task) OVERRIDE
Schedules a task to be invoked on a foreground thread wrt a specific |isolate|.
Definition:
default-platform.cc:104
v8::platform::DefaultPlatform::kMaxThreadPoolSize
static const int kMaxThreadPoolSize
Definition:
default-platform.h:42
v8::platform::DefaultPlatform::thread_pool_size_
int thread_pool_size_
Definition:
default-platform.h:46
v8::platform::TaskQueue
Definition:
task-queue.h:20
OVERRIDE
#define OVERRIDE
Definition:
compiler-specific.h:29
macros.h
mutex.h
v8
Debugger support for the V8 JavaScript engine.
Definition:
accessors.cc:20
task-queue.h
v8-platform.h
mnt
V8SourceCode
src
libplatform
default-platform.h
Generated on Tue Jul 1 2025 02:36:41 for V8 Project by
1.9.1