code-dot-org/blockly — pull request #576 by cpirich (2014-05-13 22:13:53+00:00)
Title: [finishes #70961720]: run event handlers in parallel

Re-do event handlers to support this scenario. Now you can run multiple sets of code in parallel by dragging two "repeat forever" blocks into the workspace. The free-play levels now include all of the event blocks in the toolbox and no longer populate the whenLeft/whenRight/etc. in the workspace by default. The workspace height has been increased as a result.

CS experts would recognize that each set of top-level blocks is essentially a separate thread of execution.

Event handler code is not executed and the events are not queued up if the handler is still busy from a previous event of the same type. Existing running code is not interrupted. The user needs to drag a second event block of the same type into the workspace to work around any issues caused by long-running blocks causing "dropped" events.

Rather than store a single function per event, we now register event handlers for each top-level event block (and repeat forever) and store them with an event name, function, and a command queue.

The cmdQueues top-level object has been removed.