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 // Dart test program for testing typed data. | 5 // Dart test program for testing typed data. |
6 | 6 |
7 // Library tag to be able to run in html test framework. | 7 // Library tag to be able to run in html test framework. |
8 library TypedDataIsolateTest; | 8 library TypedDataIsolateTest; |
9 | 9 |
10 import 'dart:io'; | 10 import 'dart:io'; |
11 import 'dart:isolate'; | 11 import 'dart:isolate'; |
12 import 'package:async_helper/async_helper.dart'; | 12 import 'package:async_helper/async_helper.dart'; |
13 | 13 |
14 second(message) { | 14 second(message) { |
15 var data = message[0]; | 15 var data = message[0]; |
16 var replyTo = message[1]; | 16 var replyTo = message[1]; |
17 print('got data'); | 17 print('got data'); |
18 print(data); | 18 print(data); |
19 print('printed data'); | 19 print('printed data'); |
20 replyTo.send('OK'); | 20 replyTo.send('OK'); |
21 } | 21 } |
22 | 22 |
23 main() { | 23 main() { |
24 asyncStart(); | 24 asyncStart(); |
25 new File(Platform.script.toFilePath()).readAsBytes().then((List<int> data) { | 25 new File(Platform.script.toFilePath()).readAsBytes().then((List<int> data) { |
26 var response = new ReceivePort(); | 26 var response = new ReceivePort(); |
27 var remote = Isolate.spawn(second, [data, response.sendPort]); | 27 var remote = Isolate.spawn(second, [data, response.sendPort]); |
28 response.first.then((reply) { | 28 response.first.then((reply) { |
29 print('got reply'); | 29 print('got reply'); |
30 asyncEnd(); | 30 asyncEnd(); |
31 }); | 31 }); |
32 }); | 32 }); |
33 } | 33 } |
34 | |
OLD | NEW |