I think I know one way to solve the problem with recursive even loops
First off, the problem, as explained by Luke Gorrie and others: if you
get handler1->handler2->handler1, and handler1 ends up hanging (due to
a slow client, DoS, or even a dependency between handler1 and
handler2), handler2 ends up hanging as well. OOPS.
Now, to solve this: require that all handlers are transactional. You
need a STM system that also has transactional streams. Then, when
handler1 would be about to end up on stack, and handler2 called,
_unwind_ the transaction in handler1. Again, when handler2 is about to
end up on stack, unwind it, and start handler1 again -- from the
So the event loop stops being recursive: instead of
handler1 ; abort!
handler2 ; abort!
handler1 ; complete
handler2 ; complete
...or whatever the sequence of events is.
Not particularly earth shattering, and no comment on how serious the
recursive event loop problem is -- or how practical this solution is.
I just wanted to share this, in case someone has a use for this idea.