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

Unified Diff: runtime/bin/vmservice/client/packages/observatory/src/observatory/isolate_manager.dart

Issue 24844002: Initial GUI for VM service (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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: runtime/bin/vmservice/client/packages/observatory/src/observatory/isolate_manager.dart
diff --git a/runtime/bin/vmservice/client/packages/observatory/src/observatory/isolate_manager.dart b/runtime/bin/vmservice/client/packages/observatory/src/observatory/isolate_manager.dart
new file mode 100644
index 0000000000000000000000000000000000000000..53b262cf4ab286d2cf363a8ad4eb8ba2bb19ef34
--- /dev/null
+++ b/runtime/bin/vmservice/client/packages/observatory/src/observatory/isolate_manager.dart
@@ -0,0 +1,51 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+part of observatory;
+
+/// Collection of isolates which are running in the VM. Updated
+class IsolateManager extends ObservableMixin {
+ ObservatoryApplication _application;
+ ObservatoryApplication get application => _application;
+
+ @observable final Map<int, Isolate> isolates =
+ toObservable(new Map<int, Isolate>());
+
+ static bool _foundIsolateInMembers(int id, List<Map> members) {
+ return members.any((E) => E['id'] == id);
+ }
+
+ void _responseInterceptor() {
+ _application.requestManager.responses.forEach((response) {
+ if (response['type'] == 'IsolateList') {
+ _updateIsolates(response['members']);
+ }
+ });
+ }
+
+ void _updateIsolates(List<Map> members) {
+ // Find dead isolates.
+ var deadIsolates = [];
+ isolates.forEach((k, v) {
+ if (!_foundIsolateInMembers(k, members)) {
+ deadIsolates.add(k);
+ }
+ });
+ // Remove them.
+ deadIsolates.forEach((k) {
+ print('Removing ${isolates[k]}');
+ isolates.remove(k);
+ });
+ // Add new isolates.
+ members.forEach((k) {
+ var id = k['id'];
+ var name = k['name'];
+ if (isolates[id] == null) {
+ var isolate = new Isolate(id, name);
+ print('Adding $isolate');
+ isolates[id] = isolate;
+ }
+ });
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698