Class PlayerIds

java.lang.Object
org.xxdc.oss.example.PlayerIds

public class PlayerIds extends Object
Manages player IDs for a game system. This class provides thread-safe operations for generating and retrieving player IDs.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PlayerIds(int initialValue)
    Constructs a new PlayerIds instance with the specified initial value.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Retrieves the current value of the next player ID without incrementing it.
    int
    Atomically retrieves the current value of the next player ID and increments it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PlayerIds

      public PlayerIds(int initialValue)
      Constructs a new PlayerIds instance with the specified initial value.
      Parameters:
      initialValue - The initial value for the next player ID.
  • Method Details

    • getNextId

      public int getNextId()
      Retrieves the current value of the next player ID without incrementing it.
      Returns:
      The current value of the next player ID.
    • getNextIdAndIncrement

      public int getNextIdAndIncrement()
      Atomically retrieves the current value of the next player ID and increments it.
      Returns:
      The current value of the next player ID before incrementing.