Class BoundedBuffer
java.lang.Object
com.orientechnologies.orient.core.storage.cache.chm.readbuffer.BoundedBuffer
- Type Parameters:
E- the type of elements maintained by this buffer
- All Implemented Interfaces:
Buffer
A striped, non-blocking, bounded buffer.
- Author:
- ben.manes@gmail.com (Ben Manes)
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected BufferCreates a new buffer instance after resizing to accommodate a producer.voiddrainTo(WTinyLFUPolicy consumer) Drains the buffer, sending each element to the consumer for processing.intoffer(OCacheEntry e) Inserts the specified element into this buffer if it is possible to do so immediately without violating capacity restrictions.intreads()Returns the number of elements that have been read from the buffer.intwrites()Returns the number of elements that have been written to the buffer.
-
Constructor Details
-
BoundedBuffer
public BoundedBuffer()
-
-
Method Details
-
create
Creates a new buffer instance after resizing to accommodate a producer.- Parameters:
e- the producer's element- Returns:
- a newly created buffer populated with a single element
-
offer
Description copied from interface:BufferInserts the specified element into this buffer if it is possible to do so immediately without violating capacity restrictions. The addition is allowed to fail spuriously if multiple threads insert concurrently. -
drainTo
Description copied from interface:BufferDrains the buffer, sending each element to the consumer for processing. The caller must ensure that a consumer has exclusive read access to the buffer. -
reads
public int reads()Description copied from interface:BufferReturns the number of elements that have been read from the buffer. -
writes
public int writes()Description copied from interface:BufferReturns the number of elements that have been written to the buffer.
-