Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hello world using new dart:isolate
#!/usr/bin/env dart
#import('dart:isolate', prefix:'isolate');
isolateCode() {
isolate.port.receive((msg, reply) => reply.send("re: $msg"));
}
void main() {
isolate.SendPort sendPort = isolate.spawnFunction(isolateCode);
sendPort.call("Hello World").then(print);
}
@adam-singer

This comment has been minimized.

Copy link
Owner Author

commented Mar 14, 2012

Make this script executable chmod +x ./HelloIsolate.dart and ensure dart is in your $PATH.

@sethladd

This comment has been minimized.

Copy link

commented Mar 14, 2012

Thanks Adam. Note, you don't need the prefix with the #import. Curious, do you prefer this style or was there a different motivation?

@adam-singer

This comment has been minimized.

Copy link
Owner Author

commented Mar 14, 2012

It was copied from the post http://goo.gl/p3eAf , kept it in only cause it explicitly shows what is being used from the dart:isolate module. Using it going forward I probably wouldn't prefix. Reasons I might would be naming conflicts or displaying explicit intent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.