OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 pub.asset.transformer_isolate; | 5 library pub.asset.transformer_isolate; |
6 | 6 |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 import 'dart:isolate'; | 8 import 'dart:isolate'; |
9 import 'dart:mirrors'; | 9 import 'dart:mirrors'; |
10 | 10 |
11 import 'package:barback/barback.dart'; | 11 import 'package:barback/barback.dart'; |
12 | 12 |
13 import 'serialize.dart'; | 13 import 'serialize.dart'; |
14 | 14 |
15 /// Sets up the initial communication with the host isolate. | 15 /// Sets up the initial communication with the host isolate. |
16 void loadTransformers(SendPort replyTo) { | 16 void loadTransformers(SendPort replyTo) { |
17 var port = new ReceivePort(); | 17 var port = new ReceivePort(); |
18 replyTo.send(port.sendPort); | 18 replyTo.send(port.sendPort); |
19 port.first.then((wrappedMessage) { | 19 port.listen((wrappedMessage) { |
| 20 // TODO(nweiz): When issue 19228 is fixed, spin up a separate isolate for |
| 21 // libraries loaded beyond the first so they can run in parallel. |
20 respond(wrappedMessage, (message) { | 22 respond(wrappedMessage, (message) { |
21 var library = Uri.parse(message['library']); | 23 var library = Uri.parse(message['library']); |
22 var configuration = JSON.decode(message['configuration']); | 24 var configuration = JSON.decode(message['configuration']); |
23 var mode = new BarbackMode(message['mode']); | 25 var mode = new BarbackMode(message['mode']); |
24 return _initialize(library, configuration, mode). | 26 return _initialize(library, configuration, mode). |
25 map(serializeTransformerLike).toList(); | 27 map(serializeTransformerLike).toList(); |
26 }); | 28 }); |
27 }); | 29 }); |
28 } | 30 } |
29 | 31 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 94 |
93 // Older barbacks don't support [AggregateTransformer], and calling | 95 // Older barbacks don't support [AggregateTransformer], and calling |
94 // [reflectClass] on an undefined class will throw an error, so we just define a | 96 // [reflectClass] on an undefined class will throw an error, so we just define a |
95 // null getter for them. | 97 // null getter for them. |
96 //# if barback >=0.14.1 | 98 //# if barback >=0.14.1 |
97 ClassMirror get _aggregateTransformerClass => | 99 ClassMirror get _aggregateTransformerClass => |
98 reflectClass(AggregateTransformer); | 100 reflectClass(AggregateTransformer); |
99 //# else | 101 //# else |
100 //> ClassMirror get _aggregateTransformerClass => null; | 102 //> ClassMirror get _aggregateTransformerClass => null; |
101 //# end | 103 //# end |
OLD | NEW |