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

Unified Diff: sdk/lib/_internal/lib/isolate_patch.dart

Issue 27215002: Very simple version of Isolates. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reupload due to error (500). Created 7 years, 2 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
Index: sdk/lib/_internal/lib/isolate_patch.dart
diff --git a/sdk/lib/_internal/lib/isolate_patch.dart b/sdk/lib/_internal/lib/isolate_patch.dart
index 4e6982ae430082ac93dbca7bab7d55b89829bcea..b1dd542db17a8592eec3cf562b2bacb20e56a32a 100644
--- a/sdk/lib/_internal/lib/isolate_patch.dart
+++ b/sdk/lib/_internal/lib/isolate_patch.dart
@@ -10,56 +10,41 @@ import 'dart:_isolate_helper' show IsolateNatives,
CloseToken,
JsIsolateSink;
-patch class _Isolate {
- patch static ReceivePort get port {
- if (lazyPort == null) {
- lazyPort = new ReceivePort();
- }
- return lazyPort;
+patch class Isolate {
+ patch static Future<Isolate> spawn(void entryPoint(message), var message) {
+ SendPort controlPort = IsolateNatives.spawnFunction(entryPoint, message);
+ return new Future<Isolate>.value(new Isolate._fromControlPort(controlPort));
}
- patch static SendPort spawnFunction(void topLevelFunction(),
- [bool unhandledExceptionCallback(IsolateUnhandledException e)]) {
- if (unhandledExceptionCallback != null) {
- // TODO(9012): Implement the UnhandledExceptionCallback.
- throw new UnimplementedError(
- "spawnFunction with unhandledExceptionCallback");
+ patch static Future<Isolate> spawnUri(
+ Uri uri, List<String> args, var message) {
+ if (args is List<String>) {
+ for (int i = 0; i < args.length; i++) {
+ if (args[i] is! String) {
+ throw new ArgumentError("Args must be a list of Strings $args");
+ }
+ }
+ } else if (args != null) {
+ throw new ArgumentError("Args must be a list of Strings $args");
}
- return IsolateNatives.spawnFunction(topLevelFunction);
- }
-
- patch static SendPort spawnUri(String uri) {
- return IsolateNatives.spawn(null, uri, false);
+ SendPort controlPort = IsolateNatives.spawn(uri, args, message);
+ return new Future<Isolate>.value(new Isolate._fromControlPort(controlPort));
}
}
-patch bool _isCloseToken(var object) {
- return identical(object, const CloseToken());
-}
-
/** Default factory for receive ports. */
patch class ReceivePort {
patch factory ReceivePort() {
return new ReceivePortImpl();
}
-}
-
-patch class MessageBox {
- patch MessageBox.oneShot() : this._oneShot(new ReceivePort());
- MessageBox._oneShot(ReceivePort receivePort)
- : stream = new IsolateStream._fromOriginalReceivePortOneShot(receivePort),
- sink = new JsIsolateSink.fromPort(receivePort.toSendPort());
- patch MessageBox() : this._(new ReceivePort());
- MessageBox._(ReceivePort receivePort)
- : stream = new IsolateStream._fromOriginalReceivePort(receivePort),
- sink = new JsIsolateSink.fromPort(receivePort.toSendPort());
+ patch factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) {
+ throw new UnimplementedError("ReceivePort.fromRawReceivePort");
Lasse Reichstein Nielsen 2013/10/25 14:40:03 Any plans for this?
floitsch 2013/10/25 17:46:17 I don't think I will be able to address RawReceive
+ }
}
-patch IsolateSink streamSpawnFunction(
- void topLevelFunction(),
- [bool unhandledExceptionCallback(IsolateUnhandledException e)]) {
- SendPort sendPort = spawnFunction(topLevelFunction,
- unhandledExceptionCallback);
- return new JsIsolateSink.fromPort(sendPort);
+patch class RawReceivePort {
+ patch factory RawReceivePort([void handler(event)]) {
+ throw new UnimplementedError("RawReceivePort");
+ }
}

Powered by Google App Engine
This is Rietveld 408576698