1 #include "threadimpl.h"
9 iointerrupt(Ioproc *io)
22 * first recvp acquires the ioproc.
23 * second tells us that the data is ready.
26 while(recv(io->c, &x) == -1)
28 if(x == 0) /* our cue to leave */
32 /* caller is now committed -- even if interrupted he'll return */
33 while(recv(io->creply, &x) == -1)
35 if(x == 0) /* caller backed out */
39 io->ret = io->op(&io->arg);
41 rerrstr(io->err, sizeof io->err);
42 while(send(io->creply, &io) == -1)
44 while(recv(io->creply, &x) == -1)
54 io = mallocz(sizeof(*io), 1);
56 sysfatal("ioproc malloc: %r");
57 io->c = chancreate(sizeof(void*), 0);
58 io->creply = chancreate(sizeof(void*), 0);
59 io->tid = proccreate(xioproc, io, STACK);
64 closeioproc(Ioproc *io)
69 while(send(io->c, 0) == -1)