Skip to content

Instantly share code, notes, and snippets.

@aep
Created Jul 17, 2020
Embed
What would you like to do?
using async;
using time;
using buffer;
using err;
using log;
export fn main() -> int {
new+1000 e = err::make();
new+64 driver = async::system(&e);
e.abort();
new input = async::stdio::stdin(&e);
e.abort();
new output = async::stdio::stdout(&e);
e.abort();
new read = async::future(&driver);
new write = async::future(&driver);
new+1000 mem = buffer::make();
input.read(&e, &mem, &read);
e.abort();
for (;;) {
log::info(".");
if read.state == async::State::Ready {
log::info("GOTZ STDIN %s", mem.cstr());
read.clear();
output.write(&e, mem.slice(), &write);
e.abort();
}
if write.state == async::State::Ready {
write.clear();
input.read(&e, mem.mut_slice(), &read);
e.abort();
}
driver.wait(&e);
e.abort();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment