Created
June 9, 2014 02:58
-
-
Save TrainerGuy22/e193aa61ff9f1f10c1bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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