I have a number of functions, all looking a bit like that:
while true i = peel(Q) if i == 1 && mode = 1 a, b = dosomething1(a, b) elseif i == 2 b, c = dosomething2(b, c) elseif i == 3 c, d = dosomething2(c, d) end enqueue!(Q, newevent) end
so these are event handlers based on a priority queue.
To me it looks like I want to be a bit more meta here and have something like an “engine”, but I have to be a bit careful as these are hot loops. Context ZigZagBoomerang.jl. Any pointers?