Class WorldStateIdentity

java.lang.Object
za.co.wethinkcode.robots.server.worldinfo.WorldStateIdentity

public class WorldStateIdentity extends Object
Pointer Class that holds the lastest WorldState and gracefully applies the compare and swap algorithm
  • Constructor Details

    • WorldStateIdentity

      public WorldStateIdentity(AtomicReference<WorldState> initialWorldState)
      Constructor for this WorldState Identity
      Parameters:
      initialWorldState - the WorldState that this compare and Swap started with.
  • Method Details

    • getWorldState

      public WorldState getWorldState()
      Standard getter of the World State from this class's Atomic Pointer
      Returns:
      the current WorldState
    • applyCommandSafely

      public ClientCommandResult applyCommandSafely(ClientCommand unevaluatedCommand, ClientCommandRequest req)
      Core Compare and Swap loop necessary for atomic operations. Evaluates based on worldState and only changes the state once the evaluation is complete
      Parameters:
      unevaluatedCommand - A command that has not been evaluated
      req - client command request
      Returns:
      Resolved Client Command