Class SharedData

java.lang.Object
  |
  +--SharedData

public class SharedData
extends java.lang.Object

An object of class SharedData is a named int data value used by a SharedDataProcess. The name is established when the SharedData is constructed. It can be retrieved by calling toString().

An object reading from or writing to a SharedData object takes a fixed amount of time to complete the operation. This access time is specified in the SharedDataconstructor.

When a SharedData is constructed, its value is initialized to 0. Its value is incremented by calling write(). Its value can be read by calling read(). Writers have precedence over Readers. No Reader can read the value while Writers are waiting to write the value.


Field Summary
protected static long accessTime
          accessTime is the time required to perform a data access on this SharedData.
protected  Locker locker
          locker provides the Writer locking and Reader waiting for this SharedData.
protected  java.lang.String name
          name is the name for this SharedData.
protected  int value
          value is the current value of this SharedData.
 
Constructor Summary
SharedData(java.lang.String nm, double t)
          new SharedData(nm, t) returns a new SharedData object.
 
Method Summary
protected  void doWrite()
          doWrite() increments the value of this Writer.
 void read()
          sd.read() reads the current value of sd.
 java.lang.String toString()
          sd.toString() returns the name of sd.
 void write()
          sd.write() increments the value of sd.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected int value
value is the current value of this SharedData.

accessTime

protected static long accessTime
accessTime is the time required to perform a data access on this SharedData.

locker

protected Locker locker
locker provides the Writer locking and Reader waiting for this SharedData.

name

protected java.lang.String name
name is the name for this SharedData.
Constructor Detail

SharedData

public SharedData(java.lang.String nm,
                  double t)
new SharedData(nm, t) returns a new SharedData object. The name of the new SharedData is formed by concatenating its class name with nm. Its access time is t.
Method Detail

read

public void read()
sd.read() reads the current value of sd. This method does not complete until there are no Writers waiting to write to sd.

write

public void write()
sd.write() increments the value of sd.

toString

public java.lang.String toString()
sd.toString() returns the name of sd.
Overrides:
toString in class java.lang.Object

doWrite

protected void doWrite()
doWrite() increments the value of this Writer.