Skip to content

Instantly share code, notes, and snippets.

@TrainerGuy22
Created June 9, 2014 02:58
Show Gist options
  • Select an option

  • Save TrainerGuy22/e193aa61ff9f1f10c1bf to your computer and use it in GitHub Desktop.

Select an option

Save TrainerGuy22/e193aa61ff9f1f10c1bf to your computer and use it in GitHub Desktop.
// Breeze. Utility function for instating/abstracting isolates.
Future breeze(Function func) {
ReceivePort port = new ReceivePort();
Future.wait([Isolate.spawn((SendPort port) {
func();
port.send("QUIT");
}, port.sendPort)]);
bool isReturned = false;
Future returned = new Future(() {
while(!isReturned) {}
});
port.listen((message) {
if(message == "QUIT") {
isReturned = true;
}
});
return returned;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment