I assume you mean "legacy blocking code" here. This won't work - The await will cause an (early) return with a Future<ReturnTypeOfFunction>. You need some blocking way to turn a Future<T> into a T - a mechanism they do not provide. Await is just syntactic sugar for locally creating a continuation. As I discussed earlier, this is insufficient for support legacy code because it needs to be done on every function in the call path.Brendan wrote: For legacy non-blocking code, I think you'd just do something like (e.g.) "fp = await Async.Open(filename);".
To make this concrete consider the implementation of a blocking read:
Code: Select all
ssize_t read(int fd, void *buf, size_t count)
Code: Select all
Future<ssize_t> async_read(int fd, void *buf, size_t count)
Code: Select all
ssize_t read(int fd, void *buf, size_t count) { return await async_read(fd, buf, count); }