gov.nih.nlm.mms
Class IndexEntryQueue

java.lang.Object
  extended bygov.nih.nlm.mms.IndexEntryQueue

public class IndexEntryQueue
extends Object

First In First Out queue for IndexEntry objects. A producer adds index entries until the queue is full and then blocks. A consumer reads index entries out (notifying the producer when room is available for adding more) and blocks when there are no more index entries to read. The producer wakes up the consumer when there is more data to read.

Author:
Brian Carlsen

Constructor Summary
IndexEntryQueue(int size)
          Instantiates a IndexEntryQueue with the specified size.
 
Method Summary
 IndexEntry get()
          Removes a IndexEntry from the queue, blocks if the queue is empty afterwards.
 boolean isEmpty()
          Indicates whether or not the queue is empty.
 boolean isFull()
          Indicates whether or not the queue is full.
 boolean isProducerFinished()
          Indicates whether or not the producer is finished adding IndexEntrys.
static void main(String[] s)
          Self-qa test.
 void put(IndexEntry index_entry)
          Adds a index entry to the queue, blocks if the queue is full afterwards.
 void setProducerFinished()
          Sets the flag to true indicating that the producer is finished adding IndexEntrys.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexEntryQueue

public IndexEntryQueue(int size)
Instantiates a IndexEntryQueue with the specified size.

Parameters:
size - the size of the queue
Method Detail

isProducerFinished

public boolean isProducerFinished()
Indicates whether or not the producer is finished adding IndexEntrys.

Returns:
true if so, false otherwise

setProducerFinished

public void setProducerFinished()
Sets the flag to true indicating that the producer is finished adding IndexEntrys.


isFull

public boolean isFull()
Indicates whether or not the queue is full.

Returns:
true if full, false otherwise

isEmpty

public boolean isEmpty()
Indicates whether or not the queue is empty.

Returns:
true if empty, false otherwise

put

public void put(IndexEntry index_entry)
Adds a index entry to the queue, blocks if the queue is full afterwards. Wakes up a sleeping consumer if the queue is at least 50% full.

Parameters:
index_entry - the IndexEntry to add

get

public IndexEntry get()
Removes a IndexEntry from the queue, blocks if the queue is empty afterwards. Wakes up a sleeping producer if the queue is at less than 50% full.

Returns:
the IndexEntry

main

public static void main(String[] s)
Self-qa test.

Parameters:
s - command line arguments


Copyright ©2005