An Overview of Gublists

Gublists is a collection of utility classes designed to simplify data management and inter-thread communication in multithreaded Java applications.

The foundation for these classes is a class of simple doubly-linked lists, LkList, which can contain heterogeneous sets of arbitrary objects that instantiate subclasses of the LkListElt class.

The LkList class is the basis for the FlexPipe class. A FlexPipe is a linked list of items in FIFO order that behaves like a pipe with one reader and one or more writers. Reading from a FlexPipe may be blocking or non-blocking; writing is always non-blocking, because the capacity of the pipe is limited only by available memory -- it's a linked list rather than an array. This means that a FlexPipe can easily handle arbitrarily spiky traffic, so long as the reader always eventually catches up. (For flow-controlled inter-thread communication, use PipedOutput and PipedInput.)

One basic use of FlexPipes is the movement of arbitrary arrays of bytes among data-handling threads. Non-flow-controlled instances of the ByteArrayPipe classs enable a multi-threaded application to operate at high speed consistently, unaffected by surges and lulls in data arrival rate.

This tolerance of transient peaks in traffic makes FlexPipes especially handy for implementing highly distributed systems based on network communications. Because output to a FlexPipe never blocks, slow processing of input in one node of a distributed application need never slow down the application as a whole: if network input traffic is received by one thread but processed by another, and the input data are passed from one to the other via a FlexPipe, the performance of the aggregate application is limited only by the performance of the network itself. The InetReqPipe subclass of FlexPipe is designed to simplify development of applications along these lines.

Finally, the LkList class is also the basis for the Timeline class. A Timeline is a linked list of events that are scheduled for occurrence at some time in the future. Timeline events are encapsulated in TimelineEvent objects, which are LkListElts that have scheduled occurrence times and that additionally implement the abstract method handleEvent. TimelineEvents in a Timeline are ordered by scheduled occurrence time. The Timeline object includes a background thread that watches the clock and simply calls each TimelineEvent's handleEvent method when its scheduled occurrence time is reached.

The combination of Timelines and InetReqPipes can serve as a simple but fairly powerful platform for building event-driven distributed software in Java.