OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of observatory; | 5 part of observatory; |
6 | 6 |
7 /// Collection of isolates which are running in the VM. Updated | 7 /// Collection of isolates which are running in the VM. Updated |
8 class IsolateManager extends Observable { | 8 class IsolateManager extends Observable { |
9 ObservatoryApplication _application; | 9 ObservatoryApplication _application; |
10 ObservatoryApplication get application => _application; | 10 ObservatoryApplication get application => _application; |
(...skipping 11 matching lines...) Expand all Loading... |
22 _updateIsolates(response['members']); | 22 _updateIsolates(response['members']); |
23 } | 23 } |
24 }); | 24 }); |
25 } | 25 } |
26 | 26 |
27 Isolate getIsolate(String id) { | 27 Isolate getIsolate(String id) { |
28 Isolate isolate = isolates[id]; | 28 Isolate isolate = isolates[id]; |
29 if (isolate == null) { | 29 if (isolate == null) { |
30 isolate = new Isolate.fromId(id); | 30 isolate = new Isolate.fromId(id); |
31 isolates[id] = isolate; | 31 isolates[id] = isolate; |
32 return isolate; | 32 } |
| 33 if (isolate.vmName == null) { |
| 34 // First time we are using this isolate. |
| 35 isolate.refresh(); |
33 } | 36 } |
34 return isolate; | 37 return isolate; |
35 } | 38 } |
36 | 39 |
37 void _updateIsolates(List<Map> members) { | 40 void _updateIsolates(List<Map> members) { |
38 // Find dead isolates. | 41 // Find dead isolates. |
39 var deadIsolates = []; | 42 var deadIsolates = []; |
40 isolates.forEach((k, v) { | 43 isolates.forEach((k, v) { |
41 if (!_foundIsolateInMembers(k, members)) { | 44 if (!_foundIsolateInMembers(k, members)) { |
42 deadIsolates.add(k); | 45 deadIsolates.add(k); |
43 } | 46 } |
44 }); | 47 }); |
45 // Remove them. | 48 // Remove them. |
46 deadIsolates.forEach((id) { | 49 deadIsolates.forEach((id) { |
47 isolates.remove(id); | 50 isolates.remove(id); |
48 }); | 51 }); |
49 // Add new isolates. | 52 // Add new isolates. |
50 members.forEach((map) { | 53 members.forEach((map) { |
51 var id = map['id']; | 54 var id = map['id']; |
52 var isolate = isolates[id]; | 55 var isolate = isolates[id]; |
53 if (isolate == null) { | 56 if (isolate == null) { |
54 isolate = new Isolate.fromMap(map); | 57 isolate = new Isolate.fromMap(map); |
55 isolates[id] = isolate; | 58 isolates[id] = isolate; |
56 } | 59 } |
57 isolate.refresh(); | 60 isolate.refresh(); |
58 }); | 61 }); |
59 } | 62 } |
60 } | 63 } |
OLD | NEW |