Class StateStore
java.lang.Object
tech.guilhermekaua.spigotboot.inventoryapi.internal.state.StateStore
Per-session state storage: an array indexed by token id plus the set of dirty token ids
awaiting the next coalesced flush. Owned by the session and dropped with it.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the dirty token ids and clears the dirty set.@Nullable Objectget(int id) Returns the stored value for a token id.booleanhasDirty()Returns whether any token id is currently marked dirty.voidmarkDirty(int id) Marks a token id dirty for the next flush; duplicate marks coalesce.voidStores a value for a token id, replacing any previous value.
-
Constructor Details
-
StateStore
public StateStore(int size) Creates storage sized for a view's token table.- Parameters:
size- the token count of the owning view
-
-
Method Details
-
get
Returns the stored value for a token id.- Parameters:
id- the token id- Returns:
- the stored value, or
nullwhen nothing was stored
-
set
Stores a value for a token id, replacing any previous value.- Parameters:
id- the token idvalue- the value to store, possiblynull
-
markDirty
public void markDirty(int id) Marks a token id dirty for the next flush; duplicate marks coalesce.- Parameters:
id- the token id
-
drainDirty
Returns the dirty token ids and clears the dirty set.- Returns:
- the ids marked dirty since the last drain
-
hasDirty
public boolean hasDirty()Returns whether any token id is currently marked dirty.- Returns:
truewhen a flush is pending
-