Package org.atmosphere.cpr
Class BroadcasterMembership
java.lang.Object
org.atmosphere.cpr.BroadcasterMembership
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd anAtmosphereResourceto the membership.voidclear()Clear all members.booleanCheck if the membership contains the givenAtmosphereResource.Return an unmodifiable view of the resources collection.booleanisEmpty()Return true if there are no members.iterator()Return an iterator over the resources.poll()Poll the first resource (used for FIFO policy enforcement).queue()Return the underlying concurrent queue.booleanRemove anAtmosphereResourcefrom the membership.intsize()Return the number of members.
-
Constructor Details
-
BroadcasterMembership
public BroadcasterMembership()
-
-
Method Details
-
add
Add anAtmosphereResourceto the membership.- Parameters:
r- the resource to add
-
remove
Remove anAtmosphereResourcefrom the membership.- Parameters:
r- the resource to remove- Returns:
- true if the resource was removed
-
contains
Check if the membership contains the givenAtmosphereResource.- 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
Poll the first resource (used for FIFO policy enforcement).- Returns:
- the first resource, or null if empty
-
iterator
Return an iterator over the resources.- Returns:
- an iterator
-
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
-