Cleanup: Use std::atomic<T> instead of base::AtomicNumber<T> in TaskRunner.
Bug: chromium:842083 Cq-Include-Trybots: luci.chromium.try:linux_chromium_headless_rel;master.tryserver.blink:linux_trusty_blink_rel Change-Id: I6b3f60526718f782b075bd450282646d97f6f9b5 Reviewed-on: https://chromium-review.googlesource.com/1131124 Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Commit-Queue: Hannes Payer <hpayer@chromium.org> Cr-Commit-Position: refs/heads/master@{#54385}
This commit is contained in:
parent
bf553836f2
commit
49dbb39382
@ -41,7 +41,8 @@ TaskRunner::TaskRunner(IsolateData::SetupGlobalTasks setup_global_tasks,
|
||||
ready_semaphore_(ready_semaphore),
|
||||
data_(nullptr),
|
||||
process_queue_semaphore_(0),
|
||||
nested_loop_count_(0) {
|
||||
nested_loop_count_(0),
|
||||
is_terminated_(0) {
|
||||
Start();
|
||||
}
|
||||
|
||||
@ -56,7 +57,7 @@ void TaskRunner::Run() {
|
||||
|
||||
void TaskRunner::RunMessageLoop(bool only_protocol) {
|
||||
int loop_number = ++nested_loop_count_;
|
||||
while (nested_loop_count_ == loop_number && !is_terminated_.Value()) {
|
||||
while (nested_loop_count_ == loop_number && !is_terminated_) {
|
||||
TaskRunner::Task* task = GetNext(only_protocol);
|
||||
if (!task) return;
|
||||
v8::Isolate::Scope isolate_scope(isolate());
|
||||
@ -88,13 +89,13 @@ void TaskRunner::Append(Task* task) {
|
||||
}
|
||||
|
||||
void TaskRunner::Terminate() {
|
||||
is_terminated_.Increment(1);
|
||||
is_terminated_++;
|
||||
process_queue_semaphore_.Signal();
|
||||
}
|
||||
|
||||
TaskRunner::Task* TaskRunner::GetNext(bool only_protocol) {
|
||||
for (;;) {
|
||||
if (is_terminated_.Value()) return nullptr;
|
||||
if (is_terminated_) return nullptr;
|
||||
if (only_protocol) {
|
||||
Task* task = nullptr;
|
||||
if (queue_.Dequeue(&task)) {
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "include/v8-inspector.h"
|
||||
#include "include/v8-platform.h"
|
||||
#include "include/v8.h"
|
||||
#include "src/base/atomic-utils.h"
|
||||
#include "src/base/macros.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/locked-queue-inl.h"
|
||||
@ -64,7 +63,7 @@ class TaskRunner : public v8::base::Thread {
|
||||
|
||||
int nested_loop_count_;
|
||||
|
||||
v8::base::AtomicNumber<int> is_terminated_;
|
||||
std::atomic<int> is_terminated_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(TaskRunner);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user