3
3
// https://opensource.org/licenses/MIT.
4
4
5
5
import 'dart:convert' ;
6
- import 'dart:io' ;
7
- import 'dart:isolate' ;
6
+ import 'dart:isolate' if (dart.library.js) 'js/isolate.dart' ;
8
7
import 'dart:typed_data' ;
9
8
10
- import 'package:native_synchronization/mailbox.dart' ;
11
9
import 'package:path/path.dart' as p;
12
10
import 'package:protobuf/protobuf.dart' ;
13
11
import 'package:pub_semver/pub_semver.dart' ;
14
12
import 'package:sass/sass.dart' as sass;
15
13
import 'package:sass/src/importer/node_package.dart' as npi;
16
14
15
+ import '../io.dart' ;
17
16
import '../logger.dart' ;
18
17
import '../value/function.dart' ;
19
18
import '../value/mixin.dart' ;
@@ -23,6 +22,7 @@ import 'host_callable.dart';
23
22
import 'importer/file.dart' ;
24
23
import 'importer/host.dart' ;
25
24
import 'logger.dart' ;
25
+ import 'sync_receive_port.dart' ;
26
26
import 'util/proto_extensions.dart' ;
27
27
import 'utils.dart' ;
28
28
@@ -35,8 +35,8 @@ final _outboundRequestId = 0;
35
35
/// A class that dispatches messages to and from the host for a single
36
36
/// compilation.
37
37
final class CompilationDispatcher {
38
- /// The mailbox for receiving messages from the host.
39
- final Mailbox _mailbox ;
38
+ /// The synchronous receive port for receiving messages from the host.
39
+ final SyncReceivePort _receivePort ;
40
40
41
41
/// The send port for sending messages to the host.
42
42
final SendPort _sendPort;
@@ -52,8 +52,8 @@ final class CompilationDispatcher {
52
52
late Uint8List _compilationIdVarint;
53
53
54
54
/// Creates a [CompilationDispatcher] that receives encoded protocol buffers
55
- /// through [_mailbox ] and sends them through [_sendPort] .
56
- CompilationDispatcher (this ._mailbox , this ._sendPort);
55
+ /// through [_receivePort ] and sends them through [_sendPort] .
56
+ CompilationDispatcher (this ._receivePort , this ._sendPort);
57
57
58
58
/// Listens for incoming `CompileRequests` and runs their compilations.
59
59
void listen () {
@@ -384,9 +384,9 @@ final class CompilationDispatcher {
384
384
/// Receive a packet from the host.
385
385
Uint8List _receive () {
386
386
try {
387
- return _mailbox. take ();
387
+ return _receivePort. receive ();
388
388
} on StateError catch (_) {
389
- // The [_mailbox ] has been closed, exit the current isolate immediately
389
+ // The [SyncReceivePort ] has been closed, exit the current isolate immediately
390
390
// to avoid bubble the error up as [SassException] during [_sendRequest].
391
391
Isolate .exit ();
392
392
}
0 commit comments