Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
var func = fun(){
var ret = 0;
for (var i = 0; i < 1000000; ++i) {
ret += i;
return ret;
// async takes a 0 parameter function object which is run asynchronously and
// returns a Boxed_Value (ie, any value, including void, should work)
var fut1 := async(func);
var fut2 := async(func);
var fut3 := async(func);
var fut4 := async(func);
// now join all of the futures and get their values out. If one caused an exception, the exception
// would be re-thrown now (and catchable inside of ChaiScript) retaining the same semantics
// as std::future.
print(" ${fut1.get()} ${fut2.get()} ${fut3.get()} ${fut4.get()}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.