Instances

Instances are concurrent threads of control executing a Flowchart.

Instances execute the same state machine (stack logic described by the Flowchart) but have separate contexts (env, local data, etc.).

Q: What is the role of instances in FlowCoder?
A: It is the machanism for implementing concurrent calls/transactions.

NULL Instance is a special instance. It is the only instance automatically created at the start of Flowchart execution. Other instances are created dynamically by NULL Instance as described below. We call them working instances or just instances.

All instances other than NULL Instance are called working instances or just instances.

An instance can share data with other instances via global variables and network sockets.

NULL Instance


NULL Instance is a special instance. It is the only instance automatically created at the start of Flowchart execution. NULL Instance starts at NULL State and remains in this state until the execution stops. Each time a triggering event (described below) takes place, NULL Instance spawns a new working instance.

NULL Instance:

Working instance creation

New working instance is created by NULL Instance executing one of the following Blocks under special circumstanes:

Newly created working instances are automatically enumerated. NULL Instance always has Instance ID = 0. The first working instance spawned by NULL Instance is assigned 1, the next one — 2, etc.

A new working instance inherits a copy of the Flowchart with all the associated data. The instance-scope variables are inherited at their initial values.

By Receive Block

NULL Instance creates a new working instance on reception of a packet by a Receive Block directly descending from a NULL State Block. Every packet of interest is presented to all working instances for the opportunity to accept it for processing before it is shown to NULL Instance. New working instance creation by a Receive Block happens only if none of the existing working instances accepts the packet for processing.

By Trigger Block

A new working instance is created periodically by a Trigger Block directly descending from a NULL State Block. Operations at the bottom pane of Trigger Block are executed by the newly created instance. This mechanism is usually used by a client side Flowchart.

By Timeout Block

By a Timeout Block directly descending from a NULL State Block on expiration of a global timer.

“In State” vs “In Trasition”

A working instance is “in State” ABC when it waits in ExitState Block ABC. The moment the instance starts executing one of children Blocks of the ExitState Block, it is described as “in transition” between states until it executes an EnterState Block.