def PipeSession.ask.polled

bend-pipe-session@0.2.0.0 · impl.bend:168

import bend-pipe-session@0.2.0.0/impl.bend as Impl
import Base
import bend-stdio-pipes@0.2.0.0/impl.bend as Stdio

168def PipeSession.ask.polled(
169  +pid: U32,
170  +chan: Chan(PipeSession.Answer()),
171  polled: Poll<&1, &1, Maybe<&1, PipeSession.Answer()>, Unit>
172) -> IO(Maybe<PipeSession.Answer()>):
173  match polled:
174    case Ready{Some{answer}}:
175      do IO<Maybe<PipeSession.Answer()>>:
176        Chan.close(PipeSession.Answer(), chan)
177        return Some{answer}
178    case Ready{None{}}:
179      IO.pure(Maybe<PipeSession.Answer()>, None{})
180    case Wait{_}:
181      do IO<Maybe<PipeSession.Answer()>>:
182        killed: Result<&1, &1, U32 & String, Unit> <- Stdio.kill(pid)
183        late: Maybe<&1, PipeSession.Answer()> <- Chan.recv(PipeSession.Answer(), chan)
184        Chan.close(PipeSession.Answer(), chan)
185        PipeSession.ask.late(late)

Uses (16)

Used by (1)