bsl/GLFW-b — pull request #39 by Peaker (2013-12-16 14:00:53+00:00)
Title: More Exception-safe CBs (Don't miss next scheduled CBs if any one raises an exception)

Not sure if you want to be (synchronous) exception-safe, but if you do, then my previous change would cause a problem: Any one CB raises an exception and the list of CBs to execute is lost. Rest of the CBs will be missed.

If the exception is actually handled from poll/waitEvents and does not kill the program, these semantics will be very problematic.

So I added some (unfortunately ugly, perhaps can be prettified somehow) code to keep the list of CBs to execute in the IORef and execute them safely one by one, keeping the un-executed ones in the IORef.