| OLD | NEW |
| 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'; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 ServerOperation peek() { | 57 ServerOperation peek() { |
| 58 for (Queue<ServerOperation> queue in _queues) { | 58 for (Queue<ServerOperation> queue in _queues) { |
| 59 if (!queue.isEmpty) { | 59 if (!queue.isEmpty) { |
| 60 return queue.first; | 60 return queue.first; |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 return null; | 63 return null; |
| 64 } | 64 } |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * Reschedules queued operations according their current priorities. |
| 68 */ |
| 69 void reschedule() { |
| 70 // prepare all operations |
| 71 List<ServerOperation> operations = <ServerOperation>[]; |
| 72 for (Queue<ServerOperation> queue in _queues) { |
| 73 operations.addAll(queue); |
| 74 queue.clear(); |
| 75 } |
| 76 // add all operations |
| 77 operations.forEach(add); |
| 78 } |
| 79 |
| 80 /** |
| 67 * Returns the next operation to perform or `null` if empty. | 81 * Returns the next operation to perform or `null` if empty. |
| 68 */ | 82 */ |
| 69 ServerOperation take() { | 83 ServerOperation take() { |
| 70 for (Queue<ServerOperation> queue in _queues) { | 84 for (Queue<ServerOperation> queue in _queues) { |
| 71 if (!queue.isEmpty) { | 85 if (!queue.isEmpty) { |
| 72 return queue.removeFirst(); | 86 return queue.removeFirst(); |
| 73 } | 87 } |
| 74 } | 88 } |
| 75 return null; | 89 return null; |
| 76 } | 90 } |
| 77 } | 91 } |
| OLD | NEW |