AIML Docs

Parallel Element

Element for concurrent state execution

Parallel Element

Coming soon: This feature is not yet available. Please check back soon.

The <parallel> element enables concurrent execution of multiple states:

<parallel id="concurrent">
<state id="process1">
  <transition target="done1" />
</state>
 
<state id="process2">
  <transition target="done2" />
</state>
</parallel>
PropTypeDefault
id?
string
-

Allowed Children

  • transition: State transitions
  • state: Child states
  • history: History pseudo-states
  • datamodel: Data model declarations
  • invoke: Service invocations

Examples

Basic Parallel Processing

<parallel id="dataProcessing">
<state id="validateData">
  <transition 
    event="valid" 
    target="validationComplete" 
  />
</state>
 
<state id="transformData">
  <transition 
    event="transformed" 
    target="transformationComplete" 
  />
</state>
</parallel>

Resource Management

<parallel id="resourceManager">
<datamodel>
  <data id="resources" type="JSON" value={[]} />
  <data id="errors" type="JSON" value={[]} />
</datamodel>
 
<state id="monitor">
  <script>monitorResources();</script>
</state>
 
<state id="cleanup">
  <script>manageResources();</script>
</state>
</parallel>

Service Orchestration

<parallel id="services">
<state id="api1">
  <invoke 
    type="http"
    src="https://api1.example.com"
  />
</state>
 
<state id="api2">
  <invoke 
    type="http"
    src="https://api2.example.com"
  />
</state>
 
<state id="coordinator">
  <transition 
    event="api1.done api2.done"
    target="complete"
  />
</state>
</parallel>

Usage Notes

  • All child states execute concurrently
  • Useful for independent processes
  • Can share data through parent scope
  • Transitions can span parallel regions

Common Patterns

Data Pipeline

<parallel id="pipeline">
<state id="input">
  <invoke type="service" src="inputProcessor" />
</state>
 
<state id="transform">
  <invoke type="service" src="transformer" />
</state>
 
<state id="output">
  <invoke type="service" src="outputHandler" />
</state>
 
<state id="monitor">
  <invoke type="service" src="pipelineMonitor" />
</state>
</parallel>

Service Coordination

<parallel id="services">
<state id="authentication">
  <invoke type="service" src="authService" />
  <transition event="token" target="authenticated" />
</state>
 
<state id="userProfile">
  <invoke type="service" src="profileService" />
  <transition event="profile" target="profileLoaded" />
</state>
 
<state id="preferences">
  <invoke type="service" src="preferencesService" />
  <transition event="preferences" target="preferencesLoaded" />
</state>
</parallel>

Resource Management

<parallel id="resourceManager">
<state id="allocation">
  <invoke type="service" src="resourceAllocator" />
  <transition event="lowResources" target="scaleUp" />
</state>
 
<state id="monitoring">
  <invoke type="service" src="resourceMonitor" />
  <transition event="threshold" target="alert" />
</state>
 
<state id="cleanup">
  <invoke type="service" src="resourceCleaner" />
  <transition event="cleaned" target="reset" />
</state>
</parallel>

On this page