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

Unified 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: Address comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/lib/isolate_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/isolate_patch.dart
diff --git a/runtime/lib/isolate_patch.dart b/runtime/lib/isolate_patch.dart
index 59f3a0ff0215797f88ddea6d39397e06f5cd4c0f..144e9c979444e107f3d5cf44809aea6affff44c8 100644
--- a/runtime/lib/isolate_patch.dart
+++ b/runtime/lib/isolate_patch.dart
@@ -2,6 +2,63 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+class _CloseToken {
+ /// This token is sent from [IsolateSink]s to [IsolateStream]s to ask them to
+ /// close themselves.
+ const _CloseToken();
+}
+
+patch bool _isCloseToken(var object) {
+ // TODO(floitsch): can we compare against const _CloseToken()?
+ return object is _CloseToken;
+}
+
+patch class MessageBox {
+ /* patch */ MessageBox.oneShot() : this._oneShot(new ReceivePort());
+ MessageBox._oneShot(ReceivePort receivePort)
+ : stream = new IsolateStream._fromOriginalReceivePortOneShot(receivePort),
+ sink = new _IsolateSink._fromPort(receivePort.toSendPort());
+
+ /* patch */ MessageBox() : this._(new ReceivePort());
+ MessageBox._(ReceivePort receivePort)
+ : stream = new IsolateStream._fromOriginalReceivePort(receivePort),
+ sink = new _IsolateSink._fromPort(receivePort.toSendPort());
+}
+
+class _IsolateSink implements IsolateSink {
+ bool _isClosed = false;
+ final SendPort _port;
+ _IsolateSink._fromPort(this._port);
+
+ void add(dynamic message) {
+ _port.send(message);
+ }
+
+ void addError(AsyncError errorEvent) {
+ throw new UnimplementedError("signalError on isolate streams");
+ }
+
+ void close() {
+ if (_isClosed) return;
+ add(const _CloseToken());
+ _isClosed = true;
+ }
+
+ bool operator==(var other) {
+ return other is IsolateSink && _port == other._port;
+ }
+
+ int get hashCode => _port.hashCode + 499;
+}
+
+patch IsolateSink streamSpawnFunction(
+ void topLevelFunction(),
+ [bool unhandledExceptionCallback(IsolateUnhandledException e)]) {
+ SendPort sendPort = spawnFunction(topLevelFunction,
+ unhandledExceptionCallback);
+ return new _IsolateSink._fromPort(sendPort);
+}
+
patch class ReceivePort {
/* patch */ factory ReceivePort() {
return new _ReceivePortImpl();
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/lib/isolate_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698