Package org.apache.log4j.helpers
Class BoundedFIFO
- java.lang.Object
-
- org.apache.log4j.helpers.BoundedFIFO
-
public class BoundedFIFO extends java.lang.ObjectBoundedFIFOserves as the bounded first-in-first-out buffer heavily used by theAsyncAppender.- Since:
- version 0.9.1
- Author:
- Ceki Gülcü
-
-
Constructor Summary
Constructors Constructor Description BoundedFIFO(int maxSize)Instantiate a new BoundedFIFO with a maximum size passed as argument.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LoggingEventget()Get the first element in the buffer.intgetMaxSize()Get the maximum size of the buffer.booleanisFull()Returntrueif the buffer is full, that is, whether the number of elements in the buffer equals the buffer size.intlength()Get the number of elements in the buffer.voidput(LoggingEvent o)Place aLoggingEventin the buffer.voidresize(int newSize)Resize 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.
-
-
-
Method Detail
-
get
public LoggingEvent get()
Get the first element in the buffer. Returnsnullif there are no elements in the buffer.
-
put
public void put(LoggingEvent o)
Place 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.
-
getMaxSize
public int getMaxSize()
Get the maximum size of the buffer.
-
isFull
public boolean isFull()
Returntrueif the buffer is full, that is, whether the number of elements in the buffer equals the buffer size.
-
length
public int length()
Get the number of elements in the buffer. This number is guaranteed to be in the range 0 tomaxSize(inclusive).
-
resize
public void resize(int newSize)
Resize 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.
-
-