Package org.apache.pekko.util
Class MessageBufferMap<I>
java.lang.Object
org.apache.pekko.util.MessageBufferMap<I>
- Type Parameters:
I- (Id type)
A non thread safe mutable message buffer map that can be used to buffer messages inside actors.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd an id to the buffer mapvoidAppend an element to the buffer for an id.booleanCheck if the buffer map contains an id.intRemove the buffer for an id, but publish apekko.actor.Droppedfor each dropped buffered messagevoidforeach(scala.Function2<I, MessageBuffer, scala.runtime.BoxedUnit> f) Iterate over all elements of the buffer map and apply a function to each element.voidJava APIgetOrEmpty(I id) Get the message buffer for an id, or an empty buffer if the id doesn't exist in the map.booleanisEmpty()Check if the buffer map is empty.booleannonEmpty()Check if the buffer map is not empty.voidRemove the buffer for an id.intsize()How many ids are in the buffer map.intHow many elements are in the buffers in the buffer map.
-
Constructor Details
-
MessageBufferMap
public MessageBufferMap()
-
-
Method Details
-
add
Add an id to the buffer map -
append
Append an element to the buffer for an id.- Parameters:
id- the id to add the element tomessage- the message to bufferref- the actor to buffer
-
contains
Check if the buffer map contains an id.- Parameters:
id- the id to check for- Returns:
- if the buffer contains the given id
-
drop
Remove the buffer for an id, but publish apekko.actor.Droppedfor each dropped buffered message- Returns:
- how many buffered messages were dropped
-
forEach
Java APIIterate over all elements of the buffer map and apply a function to each element.
- Parameters:
f- the function to apply to each element
-
foreach
Iterate over all elements of the buffer map and apply a function to each element.- Parameters:
f- the function to apply to each element
-
getOrEmpty
Get the message buffer for an id, or an empty buffer if the id doesn't exist in the map.- Parameters:
id- the id to get the message buffer for- Returns:
- the message buffer for the given id or an empty buffer if the id doesn't exist
-
isEmpty
public boolean isEmpty()Check if the buffer map is empty.- Returns:
- if the buffer map is empty
-
nonEmpty
public boolean nonEmpty()Check if the buffer map is not empty.- Returns:
- if the buffer map is not empty
-
remove
Remove the buffer for an id.- Parameters:
id- the id to remove the buffer for
-
size
public int size()How many ids are in the buffer map.- Returns:
- the number of ids in the buffer map
-
totalSize
public int totalSize()How many elements are in the buffers in the buffer map.- Returns:
- the number of elements in the buffers in the buffer map
-