Freezerburn / JBacon

A Functional Reactive Programming library inspired by Bacon.js
MIT License
4 stars 0 forks source link

JBacon.fromArray(...).map(F2<...>) causes program to freeze #4

Open Freezerburn opened 11 years ago

Freezerburn commented 11 years ago

This is a highly subtle and tricky bug that took me a bit to track down. Basically what happens is that fromArray will distribute a lazy event to everything that wants a value from it. For things that want a value or the event, it will asynchronously send the value. For any child EventStreams, it will send events synchronously. The lazy event that fromArray distributes doesn't actually contain a value, instead it will pull its value from a blocking queue that expects another thread to push a value onto the queue, so that the event will unblock with the value. This specific map function will (remember, this is done synchronously) attempt to get the value from the event, in order to pass it to the function and have it be evaluated/converted to an event that is acceptable for the EventStream returned by map. This will then block, and fromArray will never have the chance to push a value onto the queue, thus the entire program stops.

Not sure how to fix yet, still thinking about it.