gov.nih.nlm.mms
Class ConceptQueue

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

public class ConceptQueue
extends Object

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

Author:
Brian Carlsen

Constructor Summary
ConceptQueue(int size)
          Instantiates a ConceptQueue with the specified size.
 
Method Summary
 Concept get()
          Removes a Concept 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 Concepts.
static void main(String[] s)
          Self-qa test.
 void put(Concept concept)
          Adds a concept to the queue, blocks if the queue is full afterwards.
 void setProducerFinished()
          Sets the flag to true indicating that the producer is finished adding Concepts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConceptQueue

public ConceptQueue(int size)
Instantiates a ConceptQueue 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 Concepts.

Returns:
true if so, false otherwise

setProducerFinished

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


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(Concept concept)
Adds a concept to the queue, blocks if the queue is full afterwards. Wakes up a sleeping consumer if the queue is at least 50% full.

Parameters:
concept - the Concept to add

get

public Concept get()
Removes a Concept 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 Concept

main

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

Parameters:
s - command line arguments


Copyright ©2005