Multi-threading - Concurrent State Regions
Concurrent regions within a State represent state changes and processing that occurs in parallel inside one overall parent State. This is especially useful when one region raises events or modifies simulation variables that another region is dependent on. For example, one region could contain a simulated timer which raised events on set intervals that invoked state changes in the States within other regions.
Concurrent regions are essentially the same as Forks and Joins with similar logic and processing rules.
In the example:
- When the transition to SalesProcess is taken, each region is concurrently activated
- Credit is checked, the order totaled and the goods required packed up
- However, in the event that the Credit Check fails, this triggers the transition to the Sale Cancelled state; note that when this occurs, the entire parent state and all owned regions are immediately exited, regardless of their processing state
- If the Credit Check succeeds, the region moves to the final state and once the other regions have all reached their own final state, the parent state can then be exited