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 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 _visited.cleanup(); | 1126 _visited.cleanup(); |
1127 } | 1127 } |
1128 return result; | 1128 return result; |
1129 } | 1129 } |
1130 | 1130 |
1131 _dispatch(var x) { | 1131 _dispatch(var x) { |
1132 if (isPrimitive(x)) return visitPrimitive(x); | 1132 if (isPrimitive(x)) return visitPrimitive(x); |
1133 if (x is List) return visitList(x); | 1133 if (x is List) return visitList(x); |
1134 if (x is Map) return visitMap(x); | 1134 if (x is Map) return visitMap(x); |
1135 if (x is SendPort) return visitSendPort(x); | 1135 if (x is SendPort) return visitSendPort(x); |
1136 if (x is SendPortSync) return visitSendPortSync(x); | |
1137 | 1136 |
1138 // Overridable fallback. | 1137 // Overridable fallback. |
1139 return visitObject(x); | 1138 return visitObject(x); |
1140 } | 1139 } |
1141 | 1140 |
1142 visitPrimitive(x); | 1141 visitPrimitive(x); |
1143 visitList(List x); | 1142 visitList(List x); |
1144 visitMap(Map x); | 1143 visitMap(Map x); |
1145 visitSendPort(SendPort x); | 1144 visitSendPort(SendPort x); |
1146 visitSendPortSync(SendPortSync x); | |
1147 | 1145 |
1148 visitObject(Object x) { | 1146 visitObject(Object x) { |
1149 // TODO(floitsch): make this a real exception. (which one)? | 1147 // TODO(floitsch): make this a real exception. (which one)? |
1150 throw "Message serialization: Illegal value $x passed"; | 1148 throw "Message serialization: Illegal value $x passed"; |
1151 } | 1149 } |
1152 | 1150 |
1153 static bool isPrimitive(x) { | 1151 static bool isPrimitive(x) { |
1154 return (x == null) || (x is String) || (x is num) || (x is bool); | 1152 return (x == null) || (x is String) || (x is num) || (x is bool); |
1155 } | 1153 } |
1156 } | 1154 } |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1376 _handle = null; | 1374 _handle = null; |
1377 } else { | 1375 } else { |
1378 throw new UnsupportedError("Canceling a timer."); | 1376 throw new UnsupportedError("Canceling a timer."); |
1379 } | 1377 } |
1380 } | 1378 } |
1381 | 1379 |
1382 bool get isActive => _handle != null; | 1380 bool get isActive => _handle != null; |
1383 } | 1381 } |
1384 | 1382 |
1385 bool hasTimer() => JS('', '#.setTimeout', globalThis) != null; | 1383 bool hasTimer() => JS('', '#.setTimeout', globalThis) != null; |
OLD | NEW |