|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectOrder
CS 537, Fall 2004, Project 3. A partially-filled order for metals. It keeps track of the amounts requested and granted and serves as a waiting place for the ordering thread to wait for the order to be completely filled.
Field Summary | |
int |
seq
The sequence number of this request in the order received. |
Constructor Summary | |
Order(int id,
int[] request)
Creates a new Order. |
Method Summary | |
void |
cancel(int[] revoked)
Rejects this Order. |
void |
complete()
Signals completion. |
int |
give(int[] supply,
int limit)
Gives some resources to this Order from supply. |
boolean |
lessOrEqual(int[] amt)
Check whether the remainder of this request is less than or equal to amt (in all metals). |
int |
remaining()
Returns the remaining amount requested. |
boolean |
satisfied()
Checks whether this order is satified. |
int |
size()
Returns the total amount requested. |
String |
toString()
Turns this Order into a printable string. |
boolean |
waitFor()
Waits for this order to be fulfilled. |
Methods inherited from class Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public final int seq
Constructor Detail |
public Order(int id, int[] request)
id
- the requesting consumer's id (for debugging output).request
- the amount of each metal needed.Method Detail |
public boolean lessOrEqual(int[] amt)
amt
- the amount to compare to.
public int give(int[] supply, int limit)
supply
- the source of metals.limit
- if greater than zero, do not give more than this amount of
any resource.
public boolean satisfied()
public int size()
public int remaining()
public void complete()
public void cancel(int[] revoked)
revoked
- the place to put the revoked resources.public boolean waitFor()
public String toString()
seq:consumer[alloc1/request1,...,allocn/requestn]
where seq
is the sequence number of this Order,
consumer
is the id of the requesting Consumer,
alloci
is the amount of the ith metal already allocated
to this order, and requesti
is the initial request amount
of metal i.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |