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);"Hello World").then(print);

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?


adam-singer commented Mar 14, 2012

It was copied from the post , 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