|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectBroker
CS 537, Fall 2004, Project 3. A centralized metals broker. It receives metals from the refiner periodically and serves consumer requests as soon as possible. If it has multiple requests, it satisfies them in a variety of ways, depending on the algorithm specified in the constructor.
Field Summary |
Fields inherited from interface IBM |
GOLD, metalName, METALS, PLATINUM, URANIUM |
Constructor Summary | |
Broker(int algorithm)
Creates a new Broker. |
Method Summary | |
void |
deliver(int[] amount)
Accepts more resources from the supplier. |
boolean |
get(int id,
int[] amt)
Accepts a request from a consumer and blocks the consumer until the request can be satisfied. |
void |
run()
Main loop. |
void |
shutDown()
Tells this Broker to shut down. |
Methods inherited from class Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Broker(int algorithm)
algorithm
- the algorithm used to choose among requests.Method Detail |
public void deliver(int[] amount)
amount
- the number of each metal being delivered.public boolean get(int id, int[] amt)
id
- the requesting consumer's id (for debugging output).amt
- the request.
public void shutDown()
public void run()
run
in interface Runnable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |