Skip to main content

Threading

When writing flows, thought must be given to the notion of threading. The reason being there are two different threading models in play within most flows. The first is the full threading model that allows multiple threads of execution to run in parallel and maintains all state information for each of these independent threads of execution. The other threading model is that supported by JavaScript.

Why is this important?

The reason this is important is that when executing any nodes defined in JavaScript, care must be taken to ensure that the JavaScript system does not block other entry points. This is especially important if you have connections setup between nodes that are called asynchronously. The calls to these connections will be scheduled with the JavaScript runtime and will only execute once the JavaScript runtime has finished executing its current block of code. This should highlight the issue in that if the first block of code does not complete then the secondary blocks of code that have been scheduled with the JavaScript runtime will not execute.