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

Side by Side Diff: runtime/lib/isolate_patch.dart

Issue 12919011: Remove streamSpawnUri and mangler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class _CloseToken {
6 /// This token is sent from [IsolateSink]s to [IsolateStream]s to ask them to
7 /// close themselves.
8 const _CloseToken();
9 }
10
11 patch bool _isCloseToken(var object) {
12 // TODO(floitsch): can we compare against const _CloseToken()?
13 return object is _CloseToken;
14 }
15
16 patch class MessageBox {
17 /* patch */ MessageBox.oneShot() : this._oneShot(new ReceivePort());
18 MessageBox._oneShot(ReceivePort receivePort)
19 : stream = new IsolateStream._fromOriginalReceivePortOneShot(receivePort),
20 sink = new _IsolateSink._fromPort(receivePort.toSendPort());
21
22 /* patch */ MessageBox() : this._(new ReceivePort());
23 MessageBox._(ReceivePort receivePort)
24 : stream = new IsolateStream._fromOriginalReceivePort(receivePort),
25 sink = new _IsolateSink._fromPort(receivePort.toSendPort());
26 }
27
28 class _IsolateSink implements IsolateSink {
29 bool _isClosed = false;
30 final SendPort _port;
31 _IsolateSink._fromPort(this._port);
32
33 void add(dynamic message) {
34 _port.send(message);
35 }
36
37 void addError(AsyncError errorEvent) {
38 throw new UnimplementedError("signalError on isolate streams");
39 }
40
41 void close() {
42 if (_isClosed) return;
43 add(const _CloseToken());
44 _isClosed = true;
45 }
46
47 bool operator==(var other) {
48 return other is IsolateSink && _port == other._port;
49 }
50
51 int get hashCode => _port.hashCode + 499;
52 }
53
54 patch IsolateSink streamSpawnFunction(
55 void topLevelFunction(),
56 [bool unhandledExceptionCallback(IsolateUnhandledException e)]) {
57 SendPort sendPort = spawnFunction(topLevelFunction,
58 unhandledExceptionCallback);
59 return new _IsolateSink._fromPort(sendPort);
60 }
61
5 patch class ReceivePort { 62 patch class ReceivePort {
6 /* patch */ factory ReceivePort() { 63 /* patch */ factory ReceivePort() {
7 return new _ReceivePortImpl(); 64 return new _ReceivePortImpl();
8 } 65 }
9 } 66 }
10 67
11 class _ReceivePortImpl implements ReceivePort { 68 class _ReceivePortImpl implements ReceivePort {
12 factory _ReceivePortImpl() native "ReceivePortImpl_factory"; 69 factory _ReceivePortImpl() native "ReceivePortImpl_factory";
13 70
14 receive(void onMessage(var message, SendPort replyTo)) { 71 receive(void onMessage(var message, SendPort replyTo)) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 186 }
130 return _portInternal; 187 return _portInternal;
131 } 188 }
132 189
133 /* patch */ static spawnFunction(void topLevelFunction(), 190 /* patch */ static spawnFunction(void topLevelFunction(),
134 [bool unhandledExceptionCallback(IsolateUnhandledException e)]) 191 [bool unhandledExceptionCallback(IsolateUnhandledException e)])
135 native "isolate_spawnFunction"; 192 native "isolate_spawnFunction";
136 193
137 /* patch */ static spawnUri(String uri) native "isolate_spawnUri"; 194 /* patch */ static spawnUri(String uri) native "isolate_spawnUri";
138 } 195 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698