public class Bin
extends java.lang.Object
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 and Description |
|---|
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,
java.lang.String name)
Constructs a new bin, initially empty, with
service policy FIFO, identifier name and linked with simulator sim.
|
Bin(java.lang.String name)
Constructs a new bin, initially empty, with service policy FIFO,
identifier name and linked with the default simulator.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
java.lang.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. |
public Bin()
public Bin(ProcessSimulator sim)
sim - Simulator associated to the current variable.public Bin(java.lang.String name)
name - name associated to the binpublic Bin(ProcessSimulator sim, java.lang.String name)
sim - Simulator associated to the current variable.name - name associated to the binpublic 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 java.lang.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 variableTo submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.