V8 Project
|
#include <default-platform.h>
Public Member Functions | |
DefaultPlatform () | |
virtual | ~DefaultPlatform () |
void | SetThreadPoolSize (int thread_pool_size) |
void | EnsureInitialized () |
bool | PumpMessageLoop (v8::Isolate *isolate) |
virtual void | CallOnBackgroundThread (Task *task, ExpectedRuntime expected_runtime) OVERRIDE |
Schedules a task to be invoked on a background thread. More... | |
virtual void | CallOnForegroundThread (v8::Isolate *isolate, Task *task) OVERRIDE |
Schedules a task to be invoked on a foreground thread wrt a specific |isolate|. More... | |
![]() | |
virtual | ~Platform () |
Private Member Functions | |
DISALLOW_COPY_AND_ASSIGN (DefaultPlatform) | |
Private Attributes | |
base::Mutex | lock_ |
bool | initialized_ |
int | thread_pool_size_ |
std::vector< WorkerThread * > | thread_pool_ |
TaskQueue | queue_ |
std::map< v8::Isolate *, std::queue< Task * > > | main_thread_queue_ |
Static Private Attributes | |
static const int | kMaxThreadPoolSize = 4 |
Additional Inherited Members | |
![]() | |
enum | ExpectedRuntime { kShortRunningTask , kLongRunningTask } |
This enum is used to indicate whether a task is potentially long running, or causes a long wait. More... | |
Definition at line 24 of file default-platform.h.
v8::platform::DefaultPlatform::DefaultPlatform | ( | ) |
Definition at line 35 of file default-platform.cc.
|
virtual |
Definition at line 39 of file default-platform.cc.
References initialized_, lock_, main_thread_queue_, map, queue_, v8::platform::TaskQueue::Terminate(), and thread_pool_.
|
virtual |
Schedules a task to be invoked on a background thread.
|expected_runtime| indicates that the task will run a long time. The Platform implementation takes ownership of |task|. There is no guarantee about order of execution of tasks wrt order of scheduling, nor is there a guarantee about the thread the task will be run on.
Implements v8::Platform.
Definition at line 97 of file default-platform.cc.
References v8::platform::TaskQueue::Append(), EnsureInitialized(), and queue_.
|
virtual |
Schedules a task to be invoked on a foreground thread wrt a specific |isolate|.
Tasks posted for the same isolate should be execute in order of scheduling. The definition of "foreground" is opaque to V8.
Implements v8::Platform.
Definition at line 104 of file default-platform.cc.
References lock_, and main_thread_queue_.
Referenced by v8::platform::TEST().
|
private |
void v8::platform::DefaultPlatform::EnsureInitialized | ( | ) |
Definition at line 70 of file default-platform.cc.
References initialized_, lock_, queue_, thread_pool_, and thread_pool_size_.
Referenced by CallOnBackgroundThread(), and v8::platform::CreateDefaultPlatform().
bool v8::platform::DefaultPlatform::PumpMessageLoop | ( | v8::Isolate * | isolate | ) |
Definition at line 80 of file default-platform.cc.
References lock_, main_thread_queue_, NULL, and v8::Task::Run().
Referenced by v8::platform::TEST().
void v8::platform::DefaultPlatform::SetThreadPoolSize | ( | int | thread_pool_size | ) |
Definition at line 59 of file default-platform.cc.
References DCHECK, kMaxThreadPoolSize, lock_, v8::internal::min(), and thread_pool_size_.
Referenced by v8::platform::CreateDefaultPlatform().
|
private |
Definition at line 45 of file default-platform.h.
Referenced by EnsureInitialized(), and ~DefaultPlatform().
|
staticprivate |
Definition at line 42 of file default-platform.h.
Referenced by SetThreadPoolSize().
|
private |
Definition at line 44 of file default-platform.h.
Referenced by CallOnForegroundThread(), EnsureInitialized(), PumpMessageLoop(), SetThreadPoolSize(), and ~DefaultPlatform().
|
private |
Definition at line 49 of file default-platform.h.
Referenced by CallOnForegroundThread(), PumpMessageLoop(), and ~DefaultPlatform().
|
private |
Definition at line 48 of file default-platform.h.
Referenced by CallOnBackgroundThread(), EnsureInitialized(), and ~DefaultPlatform().
|
private |
Definition at line 47 of file default-platform.h.
Referenced by EnsureInitialized(), and ~DefaultPlatform().
|
private |
Definition at line 46 of file default-platform.h.
Referenced by EnsureInitialized(), and SetThreadPoolSize().