def timed
import bendonnect-rpc@0.1.0.0/src/transport/server.bend as Serverimport Base
245# NOTE: IO.within does not cancel the loser; a handler that overruns keeps running unobserved.
246def timed(~handle: Call -> IO(Reply), call: Call, t: Maybe<&2, U32>) -> IO(Reply):
247 match t:
248 case None{}:
249 handle(call)
250 case Some{+ms}:
251 do IO<Reply>:
252 m : Maybe<&1, Reply> <- IO.within(Reply, ms, handle(call))
253 return timed.fin(m)