Class WorldStateIdentity
java.lang.Object
za.co.wethinkcode.robots.server.worldinfo.WorldStateIdentity
Pointer Class that holds the lastest WorldState and gracefully applies the compare and swap algorithm
-
Constructor Summary
ConstructorsConstructorDescriptionWorldStateIdentity(AtomicReference<WorldState> initialWorldState) Constructor for this WorldState Identity -
Method Summary
Modifier and TypeMethodDescriptionapplyCommandSafely(ClientCommand unevaluatedCommand, ClientCommandRequest req) Core Compare and Swap loop necessary for atomic operations.Standard getter of the World State from this class's Atomic Pointer
-
Constructor Details
-
WorldStateIdentity
Constructor for this WorldState Identity- Parameters:
initialWorldState- the WorldState that this compare and Swap started with.
-
-
Method Details
-
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 evaluatedreq- client command request- Returns:
- Resolved Client Command
-