|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Order
CS 537, Fall 2002, Project 3. An order for commodities. It keeps track of the amounts requested and serves as a waiting place for the ordering thread to wait for them.
Copyright © 2002 by Marvin Solomon. All rights reserved.
Field Summary | |
private int[] |
alloc
The amount allocated thus far. |
private boolean |
done
Indication that this request has been released by calling release(). |
private int |
id
The requesting customer's id (for debugging output). |
private static int |
nextSeq
Source of sequence numbers. |
private int[] |
request
The original amount requested. |
private boolean |
result
Return code to be returned by await. |
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 | |
boolean |
await()
Await fulfillment of this order. |
void |
cancel(int[] dest)
Reject this Order. |
void |
complete()
Signal completion. |
int |
give(int[] supply,
int limit)
Give 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 commodities). |
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 an Order into a printable string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static int nextSeq
private int[] request
private int id
public final int seq
private int[] alloc
private boolean done
private boolean result
Constructor Detail |
public Order(int id, int[] request)
id
- the requesting customer's id (for debugging output).request
- the amount of each commodity 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 commodities.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[] dest)
dest
- the place to put the revoked resources.public boolean await()
public String toString()
seq:cust[alloc1/request1,...,allocn/requestn]
where seq
is the sequence number of this Order,
cust
is the id of the requesting Customer,
alloci
is the amount of the ith commodity already allocated
to this order, and requesti
is the initial request amount
of commodity i.
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |