Package org.apache.pekko.util
Class MessageBuffer
java.lang.Object
org.apache.pekko.util.MessageBuffer
A non thread safe mutable message buffer that can be used to buffer messages inside actors.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd one element to the end of the message buffer.voiddropHead()Remove the first element of the message buffer.static MessageBufferempty()Create an empty message buffer.voidIterate over all elements of the buffer and apply a function to each element.voidJava APIgetHead()Java APIhead()Return the first element of the message buffer.booleanisEmpty()Check if the message buffer is empty.booleannonEmpty()Check if the message buffer is not empty.intsize()How many elements are in the message buffer.
-
Constructor Details
-
MessageBuffer
public MessageBuffer()
-
-
Method Details
-
empty
Create an empty message buffer.- Returns:
- an empty message buffer
-
isEmpty
public boolean isEmpty()Check if the message buffer is empty.- Returns:
- if the buffer is empty
-
nonEmpty
public boolean nonEmpty()Check if the message buffer is not empty.- Returns:
- if the buffer is not empty
-
size
public int size()How many elements are in the message buffer.- Returns:
- the number of elements in the message buffer
-
append
Add one element to the end of the message buffer.- Parameters:
message- the message to bufferref- the actor to buffer- Returns:
- this message buffer
-
dropHead
public void dropHead()Remove the first element of the message buffer. -
head
Return the first element of the message buffer.- Returns:
- the first element or an element containing null if the buffer is empty
-
getHead
Java APIReturn the first element of the message buffer.
- Returns:
- the first element or an element containing null if the buffer is empty
-
foreach
Iterate over all elements of the buffer and apply a function to each element.- Parameters:
f- the function to apply to each element
-
forEach
Java APIIterate over all elements of the buffer and apply a function to each element.
- Parameters:
f- the function to apply to each element
-