Create a gist now

Instantly share code, notes, and snippets.

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);
}
Owner

adam-singer commented Mar 14, 2012

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

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

Owner

adam-singer 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