OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 _isolate_helper; | 5 library _isolate_helper; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection' show Queue, HashMap; | 8 import 'dart:collection' show Queue, HashMap; |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 import 'dart:_js_helper' show | 10 import 'dart:_js_helper' show |
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 | 1036 |
1037 operator[](var object) => null; | 1037 operator[](var object) => null; |
1038 void operator[]=(var object, var info) { } | 1038 void operator[]=(var object, var info) { } |
1039 | 1039 |
1040 void reset() { } | 1040 void reset() { } |
1041 void cleanup() { } | 1041 void cleanup() { } |
1042 | 1042 |
1043 } | 1043 } |
1044 | 1044 |
1045 /** Abstract visitor for dart objects that can be sent as isolate messages. */ | 1045 /** Abstract visitor for dart objects that can be sent as isolate messages. */ |
1046 class _MessageTraverser { | 1046 abstract class _MessageTraverser { |
1047 | 1047 |
1048 _MessageTraverserVisitedMap _visited; | 1048 _MessageTraverserVisitedMap _visited; |
1049 _MessageTraverser() : _visited = new _MessageTraverserVisitedMap(); | 1049 _MessageTraverser() : _visited = new _MessageTraverserVisitedMap(); |
1050 | 1050 |
1051 /** Visitor's entry point. */ | 1051 /** Visitor's entry point. */ |
1052 traverse(var x) { | 1052 traverse(var x) { |
1053 if (isPrimitive(x)) return visitPrimitive(x); | 1053 if (isPrimitive(x)) return visitPrimitive(x); |
1054 _visited.reset(); | 1054 _visited.reset(); |
1055 var result; | 1055 var result; |
1056 try { | 1056 try { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 for (int i = 0; i < len; i++) { | 1160 for (int i = 0; i < len; i++) { |
1161 result[i] = _dispatch(list[i]); | 1161 result[i] = _dispatch(list[i]); |
1162 } | 1162 } |
1163 return result; | 1163 return result; |
1164 } | 1164 } |
1165 | 1165 |
1166 visitSendPort(SendPort x) => throw new UnimplementedError(); | 1166 visitSendPort(SendPort x) => throw new UnimplementedError(); |
1167 } | 1167 } |
1168 | 1168 |
1169 /** Deserializes arrays created with [_Serializer]. */ | 1169 /** Deserializes arrays created with [_Serializer]. */ |
1170 class _Deserializer { | 1170 abstract class _Deserializer { |
1171 Map<int, dynamic> _deserialized; | 1171 Map<int, dynamic> _deserialized; |
1172 | 1172 |
1173 _Deserializer(); | 1173 _Deserializer(); |
1174 | 1174 |
1175 static bool isPrimitive(x) { | 1175 static bool isPrimitive(x) { |
1176 return (x == null) || (x is String) || (x is num) || (x is bool); | 1176 return (x == null) || (x is String) || (x is num) || (x is bool); |
1177 } | 1177 } |
1178 | 1178 |
1179 deserialize(x) { | 1179 deserialize(x) { |
1180 if (isPrimitive(x)) return x; | 1180 if (isPrimitive(x)) return x; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1312 _handle = null; | 1312 _handle = null; |
1313 } else { | 1313 } else { |
1314 throw new UnsupportedError("Canceling a timer."); | 1314 throw new UnsupportedError("Canceling a timer."); |
1315 } | 1315 } |
1316 } | 1316 } |
1317 | 1317 |
1318 bool get isActive => _handle != null; | 1318 bool get isActive => _handle != null; |
1319 } | 1319 } |
1320 | 1320 |
1321 bool hasTimer() => JS('', '#.setTimeout', globalThis) != null; | 1321 bool hasTimer() => JS('', '#.setTimeout', globalThis) != null; |
OLD | NEW |