Class BoundedBuffer

java.lang.Object
  extended by BoundedBuffer

public class BoundedBuffer
extends java.lang.Object

Bounded buffer.

Author:
Akitoshi Yoshida, Heinz Kredel.

Field Summary
private  java.lang.Object[] buffer
          The buffer storage of objects.
private  Sema empty
          A semaphore to indicate an empty buffer.
private  int front
          The position of the first filled cell.
private  Sema full
          A semaphore to indicate a full buffer.
private  java.lang.Object gt
           
private  java.lang.Object pt
           
private  int rear
          The position of the first empty cell.
private  int size
          The size of the buffer.
 
Constructor Summary
BoundedBuffer(int init)
          Constructs a BoundedBuffer with a desired size.
 
Method Summary
 boolean empty()
          Tests if the BoundedBuffer is empty.
 java.lang.Object get()
          Get an object from the BoundedBuffer.
 void put(java.lang.Object v)
          Put an object to the BoundedBuffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffer

private java.lang.Object[] buffer
The buffer storage of objects.


size

private int size
The size of the buffer.


front

private int front
The position of the first filled cell.


rear

private int rear
The position of the first empty cell.


empty

private Sema empty
A semaphore to indicate an empty buffer.


full

private Sema full
A semaphore to indicate a full buffer.


pt

private java.lang.Object pt

gt

private java.lang.Object gt
Constructor Detail

BoundedBuffer

public BoundedBuffer(int init)
Constructs a BoundedBuffer with a desired size.

Parameters:
init - the size of the buffer.
Method Detail

empty

public boolean empty()
Tests if the BoundedBuffer is empty. If it is, gives back the value true.

Returns:
The boolean value of (whether the BoundedBuffer is empty or not).

put

public void put(java.lang.Object v)
Put an object to the BoundedBuffer.

Parameters:
v - an object to be put to the buffer.

get

public java.lang.Object get()
Get an object from the BoundedBuffer.