4 #include "threadimpl.h"
12 iointerrupt(Ioproc *io)
25 * first recvp acquires the ioproc.
26 * second tells us that the data is ready.
29 while(recv(io->c, &x) == -1)
31 if(x == 0) /* our cue to leave */
35 /* caller is now committed -- even if interrupted he'll return */
36 while(recv(io->creply, &x) == -1)
38 if(x == 0) /* caller backed out */
42 io->ret = io->op(&io->arg);
44 rerrstr(io->err, sizeof io->err);
45 while(send(io->creply, &io) == -1)
47 while(recv(io->creply, &x) == -1)
57 io = mallocz(sizeof(*io), 1);
59 sysfatal("ioproc malloc: %r");
60 io->c = chancreate(sizeof(void*), 0);
61 io->creply = chancreate(sizeof(void*), 0);
62 io->tid = proccreate(xioproc, io, STACK);
67 closeioproc(Ioproc *io)
72 while(send(io->c, 0) == -1)