|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object Request
public class Request
A request from a Brewer to the warehouse.
CS 537, Spring 2007, Project 3.
A Request keeps track of the amounts requested and allocated thus far, and
serves as a waiting place for the ordering thread to wait for completion.
Field Summary | |
---|---|
private Order |
alloc
The amount allocated thus far. |
private boolean |
completed
Flag to indicate this Request is satisfied. |
private int |
id
The requesting customer's id (for debugging output). |
private static int |
nextSeq
Source of sequence numbers. |
private Order |
requested
The original amount requested. |
int |
seq
The sequence number of this request in the order received. |
private static int |
VERSION
Source version number. |
Constructor Summary | |
---|---|
Request(int id,
Order request)
Creates a new Request. |
Method Summary | |
---|---|
void |
await()
Await fulfillment of this order. |
void |
complete()
Signal completion. |
Order |
getAlloc()
Gets the current allocation to this request. |
int |
give(Order supply,
int limit)
Allocate some grain to this Request from supply. |
boolean |
lessOrEqual(Order supply)
Check whether the unfilled portion of this request is less than or equal to supply (in all grains). |
int |
remaining()
Return the remaining amount requested. |
boolean |
satisfied()
Check whether this order is satified. |
int |
size()
Return the total amount requested. |
String |
toString()
Turn a Request into a printable string. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final int VERSION
private static int nextSeq
private Order requested
private int id
public final int seq
private Order alloc
private boolean completed
Constructor Detail |
---|
public Request(int id, Order request)
id
- the requesting customer's id (for debugging output).request
- the amount of each commodity needed.Method Detail |
---|
public boolean lessOrEqual(Order supply)
supply
- the amount to compare to.
public int give(Order supply, int limit)
supply
- the source of grain.limit
- if greater than zero, do not give more than this many
bushels of any one grain.
public boolean satisfied()
public int size()
public int remaining()
public void complete()
public void await() throws InterruptedException
InterruptedException
- if the current thread is interrupted while
waiting for the request to be filled.public Order getAlloc()
public String toString()
toString
in class Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |