Class BroadcasterMembership

java.lang.Object
org.atmosphere.cpr.BroadcasterMembership

public class BroadcasterMembership extends Object
Encapsulates the resource membership concern for a DefaultBroadcaster.

Manages the collection of AtmosphereResource instances subscribed to a broadcaster, providing thread-safe add, remove, and query operations. Extracted from DefaultBroadcaster to separate membership management from the message dispatch hot path.

  • Constructor Details

    • BroadcasterMembership

      public BroadcasterMembership()
  • Method Details

    • add

      public void add(AtmosphereResource r)
      Add an AtmosphereResource to the membership.
      Parameters:
      r - the resource to add
    • remove

      public boolean remove(AtmosphereResource r)
      Remove an AtmosphereResource from the membership.
      Parameters:
      r - the resource to remove
      Returns:
      true if the resource was removed
    • contains

      public boolean contains(AtmosphereResource r)
      Check if the membership contains the given AtmosphereResource.
      Parameters:
      r - the resource to check
      Returns:
      true if the resource is a member
    • isEmpty

      public boolean isEmpty()
      Return true if there are no members.
      Returns:
      true if empty
    • size

      public int size()
      Return the number of members.
      Returns:
      the size
    • clear

      public void clear()
      Clear all members.
    • poll

      public AtmosphereResource poll()
      Poll the first resource (used for FIFO policy enforcement).
      Returns:
      the first resource, or null if empty
    • iterator

      public Iterator<AtmosphereResource> iterator()
      Return an iterator over the resources.
      Returns:
      an iterator
    • getResources

      public Collection<AtmosphereResource> getResources()
      Return an unmodifiable view of the resources collection.
      Returns:
      an unmodifiable collection
    • queue

      Return the underlying concurrent queue. This provides direct access for the dispatch hot path and for subclasses that need to iterate over resources.
      Returns:
      the underlying queue