(* filter-evt.sig *) (* Copyright (C) 2006 Alley Stoughton This file is part of crypto, a cryptogram encoder/decoder. See the file COPYING.txt for copying and usage restrictions *) signature FILTER_EVT = sig (* filterEvt f ev starts an internal thread, creates an 'a channel valCh and a unit channel flushCh, and returns the pair of events (recvEvt valCh, sendEvt(flushCh, ()). the thread's main loop maintains a queue of 'a values, initially empty; each iteration works as follows, using selective communication it tries to synchonize on ev, discarding the resulting value if it doesn't satisfy f, and queuing it otherwise if the buffer is nonempty, it tries to synchronize on sendEvt(valCh, v), where v is the head of the queue; if this succeeds, it dequeues v it tries to synchronize on recvEvt flushCh; if this succeeds, it empties the queue if the consumer(s) of recvEvt valCh are responsive, the queue won't become very long *) val filterEvt : ('a -> bool) -> 'a CML.event -> 'a CML.event * unit CML.event end;