Commit 2d0cad7c authored by Etienne Pierre-doray's avatar Etienne Pierre-doray Committed by Commit Bot

[Jobs API]: Expose missing pieces in Job to accommodate worklist users.

Expose:
- JobHandle::IsCompleted()
- worker_count passed as argument to GetMaxConcurrency()
- JobDelegate::GetTaskId
With default implementation. Once gin implements it, it can be made pure
virtual.

Bug: chromium:1114823
Change-Id: I24ce60d1df6adff4061c050e5aa8bf8d7bb1cf5a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2352485
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69388}
parent a7eff8cb
......@@ -170,6 +170,14 @@ class JobDelegate {
* details.
*/
virtual void NotifyConcurrencyIncrease() = 0;
/**
* Returns a task_id unique among threads currently running this job, such
* that GetTaskId() < worker count. To achieve this, the same task_id may be
* reused by a different thread after a worker_task returns.
* TODO(etiennep): Make pure virtual once custom embedders implement it.
*/
virtual uint8_t GetTaskId() { return 0; }
};
/**
......@@ -202,6 +210,12 @@ class JobHandle {
*/
virtual void Cancel() = 0;
/**
* Returns true if there's no work pending and no worker running.
* TODO(etiennep): Make pure virtual once custom embedders implement it.
*/
virtual bool IsCompleted() { return true; }
/**
* Returns true if associated with a Job and other methods may be called.
* Returns false after Join() or Cancel() was called.
......@@ -225,6 +239,17 @@ class JobTask {
* must not call back any JobHandle methods.
*/
virtual size_t GetMaxConcurrency() const = 0;
/*
* Meant to replace the version above, given the number of threads currently
* assigned to this job and executing Run(). This is useful when the result
* must include local work items not visible globaly by other workers.
* TODO(etiennep): Replace the version above by this once custom embedders are
* migrated.
*/
size_t GetMaxConcurrency(size_t worker_count) const {
return GetMaxConcurrency();
}
};
/**
......
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