How would a q implementation of Windows' waitfor
look like?
I have a q
process that feeds rows of a table, one at a time, to another process (say tickerplant).
feed:{h`.u.upd,x;};
feed each tbl;
I'd like to feed
the next row if any one of the conditions is met:
- the process receives the signal (
next
orready
) from the other process to do so;
OR
- time waiting for signal runs out (
timeout
is specific to each row oftbl
and will be provided as a column oftbl
)
Think of tbl
as containing the list of events that are to be published sequentially either when the rest of CEP/tickerplant is ready OR when the next event is due (timeout
measured as deltas timespan between the last published event and the next one, i.e. update timeout:((1 _deltas time),0Wp) from tbl
), whichever happens sooner.
I've tried while[.z.N<prevtstamp+timeout;wait()];feed x
but while
blocks the process from listening to async messages from the other process AFAIK.
Other solutions considered:
Checking for signals with .z.ts
is too slow as \t
can't go below 1ms precision.
Polling the tickerplant for next
(ready
) signal continuously from within the while
loop would slow down the tickerplant.
One solution is to maintain i
index of the current row of tbl
, separate the feeder out into two processes each handling one condition separately and polling for the current i
index. This sounds slow, compared to each
ing rows.