Chromium Code Reviews| 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 patch class _IOService { | 5 patch class _IOService { |
| 6 // Lazy initialize service ports, 32 per isolate. | 6 // Lazy initialize service ports, 32 per isolate. |
| 7 static const int _SERVICE_PORT_COUNT = 32; | 7 static const int _SERVICE_PORT_COUNT = 32; |
| 8 static List<SendPort> _servicePort = new List(_SERVICE_PORT_COUNT); | 8 static List<SendPort> _servicePort = new List(_SERVICE_PORT_COUNT); |
| 9 static ReceivePort _receivePort; | 9 static ReceivePort _receivePort; |
| 10 static SendPort _replyToPort; | 10 static SendPort _replyToPort; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 _servicePort[index].send([id, request, data], _replyToPort); | 23 _servicePort[index].send([id, request, data], _replyToPort); |
| 24 return completer.future; | 24 return completer.future; |
| 25 } | 25 } |
| 26 | 26 |
| 27 static void _initialize(int index) { | 27 static void _initialize(int index) { |
| 28 if (_servicePort[index] == null) { | 28 if (_servicePort[index] == null) { |
| 29 _servicePort[index] = _newServicePort(); | 29 _servicePort[index] = _newServicePort(); |
| 30 } | 30 } |
| 31 if (_receivePort == null) { | 31 if (_receivePort == null) { |
| 32 _receivePort = new ReceivePort(); | 32 _receivePort = new ReceivePort(); |
| 33 _replyToPort = _receivePort.toSendPort(); | 33 _replyToPort = _receivePort.sendPort; |
| 34 _receivePort.receive((data, _) { | 34 StreamSubscription subscription; |
| 35 subscription = _receivePort.listen((data) { | |
|
Ivan Posva
2013/10/24 06:48:38
This is one of those occasions where I would expec
floitsch
2013/10/24 16:15:58
just wasn't changed back yet.
done.
| |
| 35 assert(data is List && data.length == 2); | 36 assert(data is List && data.length == 2); |
| 36 _messageMap.remove(data[0]).complete(data[1]); | 37 _messageMap.remove(data[0]).complete(data[1]); |
| 37 if (_messageMap.length == 0) { | 38 if (_messageMap.length == 0) { |
| 38 _id = 0; | 39 _id = 0; |
| 39 _receivePort.close(); | 40 subscription.cancel(); |
| 40 _receivePort = null; | 41 _receivePort = null; |
| 41 } | 42 } |
| 42 }); | 43 }); |
| 43 } | 44 } |
| 44 } | 45 } |
| 45 | 46 |
| 46 static int _getNextId() { | 47 static int _getNextId() { |
| 47 if (_id == 0x7FFFFFFF) _id = 0; | 48 if (_id == 0x7FFFFFFF) _id = 0; |
| 48 return _id++; | 49 return _id++; |
| 49 } | 50 } |
| 50 | 51 |
| 51 static SendPort _newServicePort() native "IOService_NewServicePort"; | 52 static SendPort _newServicePort() native "IOService_NewServicePort"; |
| 52 } | 53 } |
| OLD | NEW |