Commit f2222403 authored by mlippautz's avatar mlippautz Committed by Commit bot

[platform] Add NumberOfAvailableBackgroundThreads

The call can be used by the embedder to provide information on the workers
executing background tasks.

BUG=chromium:524425
LOG=N

Review URL: https://codereview.chromium.org/1664203004

Cr-Commit-Position: refs/heads/master@{#33788}
parent bdfcc613
......@@ -5,6 +5,7 @@
#ifndef V8_V8_PLATFORM_H_
#define V8_V8_PLATFORM_H_
#include <stddef.h>
#include <stdint.h>
namespace v8 {
......@@ -55,6 +56,15 @@ class Platform {
virtual ~Platform() {}
/**
* Gets the number of threads that are used to execute background tasks. Is
* used to estimate the number of tasks a work package should be split into.
* A return value of 0 means that there are no background threads available.
* Note that a value of 0 won't prohibit V8 from posting tasks using
* |CallOnBackgroundThread|.
*/
virtual size_t NumberOfAvailableBackgroundThreads() { return 0; }
/**
* Schedules a task to be invoked on a background thread. |expected_runtime|
* indicates that the task will run a long time. The Platform implementation
......
......@@ -193,5 +193,10 @@ const char* DefaultPlatform::GetCategoryGroupName(
static const char dummy[] = "dummy";
return dummy;
}
size_t DefaultPlatform::NumberOfAvailableBackgroundThreads() {
return static_cast<size_t>(thread_pool_size_);
}
} // namespace platform
} // namespace v8
......@@ -34,6 +34,7 @@ class DefaultPlatform : public Platform {
bool PumpMessageLoop(v8::Isolate* isolate);
// v8::Platform implementation.
size_t NumberOfAvailableBackgroundThreads() override;
void CallOnBackgroundThread(Task* task,
ExpectedRuntime expected_runtime) override;
void CallOnForegroundThread(v8::Isolate* isolate, Task* task) override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment