Created
May 20, 2012 03:33
-
-
Save adam-singer/2740632 to your computer and use it in GitHub Desktop.
mongo dart bug in isolate. Illegal instruction: 4
This file contains 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
#import("dart:isolate"); | |
#import('../../mongo-dart/lib/mongo.dart'); | |
/* | |
1) Clone the mongo dart project and reference the correct import location | |
2) dart test_isolate.dart | |
13:37:00-adam@Adams-MacBook-Air:~/dart/test | |
$ dart test_isolate.dart | |
enter find | |
Illegal instruction: 4 | |
*/ | |
// class used for simple async class | |
class AnotherAsyncClass { | |
Future open() { | |
Completer c = new Completer(); | |
c.complete("blamamal"); | |
return c.future; | |
} | |
} | |
Future<String> find(msg) { | |
print("enter find"); | |
Completer completer = new Completer(); | |
// Creates the following error: Illegal instruction: 4 | |
Db db = new Db('some-db-test'); | |
completer.complete("some dummy data, comment out to test db.open() or a.open()"); | |
// DbCollection collection; | |
// AnotherAsyncClass a = new AnotherAsyncClass(); | |
// a.open().then((_) { | |
// | |
// }); | |
// print("before db.open in find"); | |
// db.open().chain((_){ | |
// print("open db in find"); | |
// collection = db.collection("somecollection"); | |
// return collection.findOne({"somefield":msg}); | |
// }).chain((v){ | |
// completer.complete(v); | |
// }); | |
print("ret find"); | |
return completer.future; | |
} | |
new_isolate() { | |
port.receive((msg, reply) { | |
Future f = find(msg); | |
f.handleException((e)=>print("e = ${e}")); | |
f.then((r)=>reply.send(r)); | |
}); | |
} | |
main() { | |
spawnFunction(new_isolate).call("findme").then((s)=>print("s=$s")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment