Package org.apache.log4j.helpers
Class BoundedFIFO
java.lang.Object
org.apache.log4j.helpers.BoundedFIFO
Bounded first-in-first-out buffer.
- Since:
- version 0.9.1
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) LoggingEvent[](package private) int(package private) int(package private) int(package private) int -
Constructor Summary
ConstructorsConstructorDescriptionBoundedFIFO(int maxSize) Constructs a new instance with a maximum size passed as argument. -
Method Summary
Modifier and TypeMethodDescriptionget()Gets the first element in the buffer.intGets the maximum size of the buffer.booleanisFull()Returnstrueif the buffer is full, that is, whether the number of elements in the buffer equals the buffer size.intlength()Gets the number of elements in the buffer.(package private) intmin(int a, int b) voidput(LoggingEvent o) Puts aLoggingEventin the buffer.voidresize(int newSize) Resizes the buffer to a new size.booleanwasEmpty()Returnstrueif there is just one element in the buffer.booleanwasFull()Returnstrueif the number of elements in the buffer plus 1 equals the maximum buffer size, returnsfalseotherwise.
-
Field Details
-
buf
LoggingEvent[] buf -
numElements
int numElements -
first
int first -
next
int next -
maxSize
int maxSize
-
-
Constructor Details
-
BoundedFIFO
public BoundedFIFO(int maxSize) Constructs a new instance with a maximum size passed as argument.
-
-
Method Details
-
get
Gets the first element in the buffer. Returnsnullif there are no elements in the buffer. -
getMaxSize
public int getMaxSize()Gets the maximum size of the buffer. -
isFull
public boolean isFull()Returnstrueif the buffer is full, that is, whether the number of elements in the buffer equals the buffer size. -
length
public int length()Gets the number of elements in the buffer. This number is guaranteed to be in the range 0 tomaxSize(inclusive). -
min
int min(int a, int b) -
put
Puts aLoggingEventin the buffer. If the buffer is full then the event is silently dropped. It is the caller's responsability to make sure that the buffer has free space. -
resize
public void resize(int newSize) Resizes the buffer to a new size. If the new size is smaller than the old size events might be lost.- Since:
- 1.1
-
wasEmpty
public boolean wasEmpty()Returnstrueif there is just one element in the buffer. In other words, if there were no elements before the lastput(org.apache.log4j.spi.LoggingEvent)operation completed. -
wasFull
public boolean wasFull()Returnstrueif the number of elements in the buffer plus 1 equals the maximum buffer size, returnsfalseotherwise.
-