Breakout Problem Set Javadocs

cs101.util.semaphore
Class IntBuffer

java.lang.Object
  extended bycs101.util.semaphore.IntBuffer

public final class IntBuffer
extends java.lang.Object

Implements a producer/consumer synchronized buffer.
Interface is IntBuffer.putButton( int ), IntBuffer.getButton(). This class does guarantee that no value written to it will be overwritten before it has been read and also guarantees that once a value has been read it will not be re-read on subsequent attempts.

This class only behaves well when a single thread is reading the buffer and a single thread is writing to the buffer, or the order in which events are processed is unimportant. This class doesn't guarantee that competing threads will get to write in a sensible order, and does not guarantee that competing threads will get to read from the buffer in a sensible order

Version:
$Id: IntBuffer.java,v 1.9 2003/09/23 15:37:30 gus Exp $
Author:
Lynn Andrea Stein, las@ai.mit.edu, Patrick G. Heck, gus.heck@olin.edu
See Also:
BS

Constructor Summary
IntBuffer()
           
 
Method Summary
 int getButton()
          An alternate (caluculator oriented) name for getInt().
 int getInt()
          (Safely) Consumes the int held in the IntBuffer.
 void putButton(int newButton)
          An alternate (calculator oriented) name for putInt(int).
 void putInt(int newButton)
          (Safely) Puts an int into the IntBuffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntBuffer

public IntBuffer()
Method Detail

putButton

public void putButton(int newButton)
An alternate (calculator oriented) name for putInt(int).

Parameters:
newButton - the button to be inserted.
See Also:
getButton(), BS

getButton

public int getButton()
An alternate (caluculator oriented) name for getInt().

Returns:
the next button.
See Also:
putButton(int), BS

putInt

public void putInt(int newButton)
(Safely) Puts an int into the IntBuffer.

Parameters:
newButton - the value to be inserted.
See Also:
getButton(), BS

getInt

public int getInt()
(Safely) Consumes the int held in the IntBuffer.

Returns:
the integer value.
See Also:
putButton(int), BS

Breakout Problem Set Javadocs