Synchronization

Sometimes before performing the appropriate operations on commands they must be gathered from different flows asynchronously.

Typically in a parallel game players send their orders asynchronously, whereas a serial game is driven by the commands synchronously : player send orders to the moderator which replies with result and updates immediatly.



Furthermore commands can be considered as :

  • instant : executed immediatly
  • delayed : executed later when needed (upon turn processing most likely)

Instant Commands

Instant commands do not require any synchronization mechanism : they are simply executed as soon as received.



A chat order has to be instant because it has nothing to do with the turn processing.

A move order in the game of chess also has to be instant because this game is serial and therefore the game control is driven by players actions.

Delayed commands

In the board game Diplomacy players send their orders asynchronously.



Until they get processed delayed commands have to be stored, which is the main purpose of the barrier.

Barrier

The barrier bufferizes all commands it receives and releases them as a single flow once a specific condition is met.

Some typical release conditions are :

  • all players have finished posting their orders
  • all updates and results have been received for this turn
  • the time allowed for the turn is over

Those conditions hence fall into two different types :

  • internal : the barrier detects that the condition is met
  • external : an arbitrary event triggers the release

A barrier is typically based on the buffer component with extra features to cope with the different release modes.

Commit

The role of this special command is to notify a barrier that the command flow can be marked as finished.

Once all command flows are marked, the barrier automatically releases the commands.



If other commands arrive from a marked flow, it gets unmarked.



As soon as the barrier has released the commands it unmarks all flows.

Pb to ID incomming flows : use User ?