Skip to content

Commit

Permalink
[Jobs API]: Implement JobDelegate::IsJoiningThread.
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
Etienne Pierre-doray authored and Commit Bot committed Sep 22, 2020
1 parent b1b3ccb commit bcff179
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions base/task/post_job.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
1 change: 1 addition & 0 deletions gin/v8_platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down

0 comments on commit bcff179

Please sign in to comment.