Brendan wrote:
For legacy non-blocking code, I think you'd just do something like (e.g.) "fp = await Async.Open(filename);".
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.
To make this concrete consider the implementation of a blocking read:
Code:
ssize_t read(int fd, void *buf, size_t count)
and I am provided the following non-blocking interface from the system:
Code:
Future<ssize_t> async_read(int fd, void *buf, size_t count)
Don't worry about the particulars of the interface here. Suffice it to say, the read is complete when the returned future resolves. If I implement the blocking read as follows:
Code:
ssize_t read(int fd, void *buf, size_t count) { return await async_read(fd, buf, count); }
Then it would be a compiler bug, my return type is not a Future and so await cannot be used.