Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: test/inspector-protocol/task-queue.cc

Issue 2358943002: [inspector] added inspector protocol test runner (Closed)
Patch Set: a Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "test/inspector-protocol/task-queue.h"
6
7 #include "test/inspector-protocol/task.h"
8
9 namespace {
10 const int kTaskQueueIndex = 2;
11 }
12
13 namespace v8_inspector {
14
15 TaskQueue::TaskQueue() : process_queue_semaphore_(0) {}
16
17 TaskQueue::~TaskQueue() {}
18
19 void TaskQueue::Append(Task* task) {
20 queue_.Enqueue(task);
21 process_queue_semaphore_.Signal();
22 }
23
24 Task* TaskQueue::GetNext(bool only_protocol) {
25 for (;;) {
26 if (only_protocol) {
27 for (;;) {
28 Task* task = nullptr;
29 if (!queue_.Dequeue(&task)) break;
30 if (task->is_protocol_task()) return task;
31 deffered_queue_.Enqueue(task);
32 }
33 } else {
34 Task* task = nullptr;
35 if (deffered_queue_.Dequeue(&task)) return task;
36 if (queue_.Dequeue(&task)) return task;
37 }
38 process_queue_semaphore_.Wait();
39 }
40 }
41
42 void TaskQueue::SetContext(v8::Local<v8::Context> context) {
43 context->SetAlignedPointerInEmbedderData(kTaskQueueIndex, this);
44 }
45
46 TaskQueue* TaskQueue::FromContext(v8::Local<v8::Context> context) {
47 return static_cast<TaskQueue*>(
48 context->GetAlignedPointerFromEmbedderData(kTaskQueueIndex));
49 }
50
51 } // v8_inspector
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698