0

[Jobs API]: Implement JobDelegate::IsJoiningThread.

To let the user do special handling on the main thread e.g. Scavenging
uses different tracing categories for background/foreground threads.

Change-Id: I001b669e318bf88f39358ddb96482ec5ed4b62a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2418986
Reviewed-by: François Doray <fdoray@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809328}
This commit is contained in:
Etienne Pierre-doray
2020-09-22 14:53:53 +00:00
committed by Commit Bot
parent b1b3ccbd57
commit bcff179ae4
2 changed files with 7 additions and 0 deletions

@ -57,6 +57,12 @@ class BASE_EXPORT JobDelegate {
// reused by a different thread after a worker_task returns.
uint8_t GetTaskId();
// Returns true if the current task is called from the thread currently
// running JobHandle::Join().
bool IsJoiningThread() const {
return pooled_task_runner_delegate_ == nullptr;
}
private:
static constexpr uint8_t kInvalidTaskId = std::numeric_limits<uint8_t>::max();

@ -284,6 +284,7 @@ class JobDelegateImpl : public v8::JobDelegate {
delegate_->NotifyConcurrencyIncrease();
}
uint8_t GetTaskId() override { return delegate_->GetTaskId(); }
bool IsJoiningThread() const override { return delegate_->IsJoiningThread(); }
private:
base::JobDelegate* delegate_;