Created
July 17, 2020 09:20
-
-
Save aep/a90a75a71a777f3b3e8d005506af82b8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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