Package org.apache.pekko.util
Class MessageBufferMap<I>
- java.lang.Object
-
- org.apache.pekko.util.MessageBufferMap<I>
-
- Type Parameters:
I
- (Id type)
public final class MessageBufferMap<I> extends java.lang.Object
A non thread safe mutable message buffer map that can be used to buffer messages inside actors.
-
-
Constructor Summary
Constructors Constructor Description MessageBufferMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(I id)
Add an id to the buffer mapvoid
append(I id, java.lang.Object message, ActorRef ref)
Append an element to the buffer for an id.boolean
contains(I id)
Check if the buffer map contains an id.int
drop(I id, java.lang.String reason, ActorRef deadLetters)
Remove the buffer for an id, but publish apekko.actor.Dropped
for each dropped buffered messagevoid
foreach(scala.Function2<I,MessageBuffer,scala.runtime.BoxedUnit> f)
Iterate over all elements of the buffer map and apply a function to each element.void
forEach(Procedure2<I,MessageBuffer> f)
Java APIMessageBuffer
getOrEmpty(I id)
Get the message buffer for an id, or an empty buffer if the id doesn't exist in the map.boolean
isEmpty()
Check if the buffer map is empty.boolean
nonEmpty()
Check if the buffer map is not empty.void
remove(I id)
Remove the buffer for an id.int
size()
How many ids are in the buffer map.int
totalSize()
How many elements are in the buffers in the buffer map.
-
-
-
Method Detail
-
add
public void add(I id)
Add an id to the buffer map
-
append
public void append(I id, java.lang.Object message, ActorRef ref)
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
public boolean contains(I id)
Check if the buffer map contains an id.- Parameters:
id
- the id to check for- Returns:
- if the buffer contains the given id
-
drop
public int drop(I id, java.lang.String reason, ActorRef deadLetters)
Remove the buffer for an id, but publish apekko.actor.Dropped
for each dropped buffered message- Returns:
- how many buffered messages were dropped
-
forEach
public void forEach(Procedure2<I,MessageBuffer> f)
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
public void foreach(scala.Function2<I,MessageBuffer,scala.runtime.BoxedUnit> f)
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
public MessageBuffer getOrEmpty(I id)
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
public void remove(I id)
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
-
-