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

Side by Side Diff: pkg/analysis_server/lib/src/operation/operation_queue.dart

Issue 1008443002: Cherry-pick r44373, r44378, and r44275. (Closed) Base URL: https://dart.googlecode.com/svn/trunk/dart
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library operation.queue; 5 library operation.queue;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analysis_server/src/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/operation/operation.dart'; 10 import 'package:analysis_server/src/operation/operation.dart';
11 import 'package:analyzer/src/generated/engine.dart';
11 import 'package:analyzer/src/generated/source.dart'; 12 import 'package:analyzer/src/generated/source.dart';
12 13
13 /** 14 /**
14 * A queue of operations in an [AnalysisServer]. 15 * A queue of operations in an [AnalysisServer].
15 */ 16 */
16 class ServerOperationQueue { 17 class ServerOperationQueue {
17 final List<Queue<ServerOperation>> _queues = <Queue<ServerOperation>>[]; 18 final List<Queue<ServerOperation>> _queues = <Queue<ServerOperation>>[];
18 19
19 ServerOperationQueue() { 20 ServerOperationQueue() {
20 for (int i = 0; i < ServerOperationPriority.COUNT; i++) { 21 for (int i = 0; i < ServerOperationPriority.COUNT; i++) {
(...skipping 23 matching lines...) Expand all
44 /** 45 /**
45 * Removes all elements in the queue. 46 * Removes all elements in the queue.
46 */ 47 */
47 void clear() { 48 void clear() {
48 for (Queue<ServerOperation> queue in _queues) { 49 for (Queue<ServerOperation> queue in _queues) {
49 queue.clear(); 50 queue.clear();
50 } 51 }
51 } 52 }
52 53
53 /** 54 /**
55 * The given [context] has been removed, so all pending operations that refer
56 * to it should be removed from the queue.
57 */
58 void contextRemoved(AnalysisContext context) {
59 for (Queue<ServerOperation> queue in _queues) {
60 queue.removeWhere((operation) => operation.context == context);
61 }
62 }
63
64 /**
54 * Return the next operation to perform, or `null` if the queue is empty. 65 * Return the next operation to perform, or `null` if the queue is empty.
55 * This method does not change the queue. 66 * This method does not change the queue.
56 */ 67 */
57 ServerOperation peek() { 68 ServerOperation peek() {
58 for (Queue<ServerOperation> queue in _queues) { 69 for (Queue<ServerOperation> queue in _queues) {
59 if (!queue.isEmpty) { 70 if (!queue.isEmpty) {
60 return queue.first; 71 return queue.first;
61 } 72 }
62 } 73 }
63 return null; 74 return null;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 for (var operation in queue) { 122 for (var operation in queue) {
112 if (test(operation)) { 123 if (test(operation)) {
113 queue.remove(operation); 124 queue.remove(operation);
114 return operation; 125 return operation;
115 } 126 }
116 } 127 }
117 } 128 }
118 return null; 129 return null;
119 } 130 }
120 } 131 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/operation/operation_analysis.dart ('k') | pkg/analysis_server/test/analysis_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698