|
SSJ V. 2.6. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object umontreal.iro.lecuyer.simprocs.Bin
public class Bin
A Bin corresponds to a pile of identical tokens, and a list of
processes waiting for the tokens when the list is empty.
It is a producer/consumer process synchronization device.
Tokens can be added to the pile (i.e., produced) by the
method put
.
A process can request tokens from the pile (i.e., consume)
by calling take
.
The behavior of a Bin is somewhat similar to that of a
Resource
. Each Bin has a single queue of waiting
processes, with FIFO or LIFO service policy, and
which can be accessed via the method waitList
.
This list actually contains objects of the class UserRecord
.
Each UserRecord
points to a process
and contains some additional information.
Constructor Summary | |
---|---|
Bin()
Constructs a new bin, initially empty, with service policy FIFO and linked with the default simulator. |
|
Bin(ProcessSimulator sim)
Constructs a new bin, initially empty, with service policy FIFO and linked with simulator sim. |
|
Bin(ProcessSimulator sim,
String name)
Constructs a new bin, initially empty, with service policy FIFO, identifier name and linked with simulator sim. |
|
Bin(String name)
Constructs a new bin, initially empty, with service policy FIFO, identifier name and linked with the default simulator. |
Method Summary | |
---|---|
int |
getAvailable()
Returns the number of available tokens for this bin. |
void |
init()
Reinitializes this bin by clearing up its pile of tokens and its waiting list. |
void |
initStat()
Reinitializes all the statistical collectors for this bin. |
void |
put(int n)
Adds n tokens to this bin. |
String |
report()
Returns a string containing a complete statistical report on this bin. |
void |
setPolicyFIFO()
Sets the service policy for ordering processes waiting for tokens on the bin to FIFO (first in, first out): the processes are placed in the list (and served) according to their order of arrival. |
void |
setPolicyLIFO()
Sets the service policy for ordering processes waiting for tokens on the bin to LIFO (last in, first out): the processes are placed in the list (and served) according to their inverse order of arrival: the last arrived are served first. |
void |
setSimulator(ProcessSimulator sim)
Set the current simulator of this continuous-time variable. |
void |
setStatCollecting(boolean b)
Starts or stops collecting statistics on the list returned by waitList for this bin. |
Simulator |
simulator()
Returns the current simulator of this continuous-time variable. |
Accumulate |
statOnAvail()
Returns the statistical collector for the available tokens on the bin as a function of time. |
void |
take(int n)
The executing process invoking this method requests n tokens from this bin. |
LinkedListStat |
waitList()
Returns the list of UserRecord
for the processes waiting for tokens from this bin. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Bin()
public Bin(ProcessSimulator sim)
sim
- Simulator associated to the current variable.public Bin(String name)
name
- name associated to the binpublic Bin(ProcessSimulator sim, String name)
sim
- Simulator associated to the current variable.name
- name associated to the binMethod Detail |
---|
public void init()
public void setStatCollecting(boolean b)
waitList
for this bin.
If the statistical collection is turned ON, It also constructs (if not yet done)
and initializes an additional statistical
collector of class
Accumulate
for this bin. This collector will be updated
automatically. It can be accessed via statOnAvail
, and
monitors the evolution of the
available tokens of the bin
as a function of time.
b
- true to turn statistical collection ON, false to turn it OFFpublic void initStat()
setStatCollecting
(true) must have been invoked earlier for
this bin.
public void setPolicyFIFO()
public void setPolicyLIFO()
public int getAvailable()
public void take(int n)
waitList
list (the queue) for this bin and is suspended
until it can obtain the requested number of tokens.
n
- number of requested tokenspublic void put(int n)
n
- number of tokens to put into the binpublic LinkedListStat waitList()
UserRecord
for the processes waiting for tokens from this bin.
public Accumulate statOnAvail()
setStatCollecting
(true)
has been invoked previously.
public String report()
setStatCollecting
(true) must have
been invoked previously, otherwise no statistics will have been collected.
The report contains statistics on the available tokens, queue size and
waiting time for this bin.
public Simulator simulator()
public void setSimulator(ProcessSimulator sim)
sim
- the simulator of the current variable
|
SSJ V. 2.6. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |