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

Unified Diff: pkg/analysis_server/lib/src/operation/operation_queue.dart

Issue 1327173002: Make NavigationOperation a MergeableOperation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/operation/operation_queue.dart
diff --git a/pkg/analysis_server/lib/src/operation/operation_queue.dart b/pkg/analysis_server/lib/src/operation/operation_queue.dart
index ced4a8c9e54f74c59d2c92e382f5b5fc6558d6b0..1687a4bc3209fdde14a7f59a7d712b52d8ac24e4 100644
--- a/pkg/analysis_server/lib/src/operation/operation_queue.dart
+++ b/pkg/analysis_server/lib/src/operation/operation_queue.dart
@@ -39,6 +39,14 @@ class ServerOperationQueue {
void add(ServerOperation operation) {
int queueIndex = operation.priority.ordinal;
Queue<ServerOperation> queue = _queues[queueIndex];
+ // try to merge into an existing operation
+ for (ServerOperation existingOperation in queue) {
+ if (existingOperation is MergeableOperation &&
+ existingOperation.merge(operation)) {
+ return;
+ }
+ }
+ // add it
queue.addLast(operation);
}
@@ -119,7 +127,7 @@ class ServerOperationQueue {
*/
ServerOperation takeIf(bool test(ServerOperation operation)) {
for (Queue<ServerOperation> queue in _queues) {
- for (var operation in queue) {
+ for (ServerOperation operation in queue) {
if (test(operation)) {
queue.remove(operation);
return operation;

Powered by Google App Engine
This is Rietveld 408576698