Buffered OsidList Pattern

Decouple producer from consumer — buffer any OsidList on a virtual thread.

Overview

A buffered OsidList wraps an underlying list and drains it on a virtual thread into a bounded, lock-free queue (a YACBQueue, DISRUPTOR by default). The producer thread fills the buffer ahead of the consumer, so a slow upstream source no longer stalls the reader and a slow reader no longer stalls the source — the two run independently up to the buffer's capacity.

Use the buffered list to smooth out a list whose getNextOsidObject() performs blocking I/O, or to prefetch while the consumer is busy with the previous element.

Javadoc Reference

net.okapia.osid.streams.spi

Class Declaration Pattern

public final class BufferedOsidObjectList
extends AbstractBufferedOsidList<OsidObject>
implements OsidObjectList

Constructor Pattern

BufferedOsidObjectList(OsidObjectList list)
BufferedOsidObjectList(OsidObjectList list, int bufferSize)
ParameterTypeDescription
list OsidObjectList the underlying list to buffer
bufferSize int the capacity of the bounded buffer (optional defaults to 256