Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: lib/src/raw_receive_port_multiplexer.dart

Issue 1025293003: pkg/isolate: library renaming, removed unused method, fix creation of TimeoutException (Closed) Base URL: https://github.com/dart-lang/isolate.git@master
Patch Set: nits Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/multiplexport.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /// A multiplexing [RawReceivePort]. 5 /// A multiplexing [RawReceivePort].
6 /// 6 ///
7 /// Allows creating a number of [RawReceivePort] implementations that all send 7 /// Allows creating a number of [RawReceivePort] implementations that all send
8 /// messages through the same real `RawReceivePort`. 8 /// messages through the same real `RawReceivePort`.
9 /// 9 ///
10 /// This allows reducing the number of receive ports created, but adds an 10 /// This allows reducing the number of receive ports created, but adds an
11 /// overhead to each message. 11 /// overhead to each message.
12 /// If a library creates many short-lived receive ports, multiplexing might be 12 /// If a library creates many short-lived receive ports, multiplexing might be
13 /// faster. 13 /// faster.
14 /// 14 ///
15 /// To use multiplexing receive ports, create and store a 15 /// To use multiplexing receive ports, create and store a
16 /// [RawReceivePortMultiplexer], and create receive ports by calling 16 /// [RawReceivePortMultiplexer], and create receive ports by calling
17 /// `multiplexer.createRawReceivePort(handler)` where you would otherwise 17 /// `multiplexer.createRawReceivePort(handler)` where you would otherwise
18 /// write `new RawReceivePort(handler)`. 18 /// write `new RawReceivePort(handler)`.
19 /// 19 ///
20 /// Remember to [close] the multiplexer when it is no longer needed. 20 /// Remember to [close] the multiplexer when it is no longer needed.
21 /// ` 21 ///
22 /// (TODO: Check if it really is faster - creating a receive port requires a 22 /// (TODO: Check if it really is faster - creating a receive port requires a
23 /// global mutex, so it may be a bottleneck, but it's not clear how slow it is). 23 /// global mutex, so it may be a bottleneck, but it's not clear how slow it is).
24 library pkg.isolate.multiplexreceiveport; 24 library isolate.raw_receive_port_multiplexer;
25 25
26 import "dart:isolate"; 26 import 'dart:collection';
27 import "dart:collection"; 27 import 'dart:isolate';
28 import "lists.dart"; 28
29 import 'lists.dart';
29 30
30 class _MultiplexRawReceivePort implements RawReceivePort { 31 class _MultiplexRawReceivePort implements RawReceivePort {
31 final RawReceivePortMultiplexer _multiplexer; 32 final RawReceivePortMultiplexer _multiplexer;
32 final int _id; 33 final int _id;
33 Function _handler; 34 Function _handler;
34 35
35 _MultiplexRawReceivePort(this._multiplexer, this._id, this._handler); 36 _MultiplexRawReceivePort(this._multiplexer, this._id, this._handler);
36 37
37 void set handler(void handler(response)) { 38 void set handler(void handler(response)) {
38 this._handler = handler; 39 this._handler = handler;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 93 }
93 94
94 SendPort _createSendPort(int id) { 95 SendPort _createSendPort(int id) {
95 return new _MultiplexSendPort(id, _port.sendPort); 96 return new _MultiplexSendPort(id, _port.sendPort);
96 } 97 }
97 98
98 void _closePort(int id) { 99 void _closePort(int id) {
99 _map.remove(id); 100 _map.remove(id);
100 } 101 }
101 } 102 }
OLDNEW
« no previous file with comments | « lib/src/multiplexport.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698