|
DRCL J-Sim API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectdrcl.DrclObj
drcl.comp.queue.QLogic
This class is the base class for queue logic. The purpose of this class is to separate the logic of deciding whether or not to enqueue an object, from the actual actions of enqueuing/discarding/dequeuing an object. It makes it possible to construct a complex queue structure where one can plug in different logic to form a specific queue implementation.
This class defines the interfaces of that decision logic.
Specifically, a subclass must implement adviceOn(data_, size_).
The method returns null if it is ok to enqueue the data of the specified size.
It returns a non-null string (advice) if it advices to discard the data.
The caller may or may not take the advice. But regardless of which action to take, the caller
must call the corresponding event handlers (dropHandler(),
enqueueHandler() and
dequeueHandler()) of this queue logic so that this queue
logic can maintain the appropriate picture of what the real queue (the caller maintains) is like
in order to give correct advices later on.
This class implements a simple limited-capacity queue logic.
| Field Summary | |
int |
capacity
The capacity of the queue. |
static java.lang.String |
EVENT_QSIZE
Name of the instant queue size change event. |
int |
qlen
The current queue length (# of objects in the queue). |
int |
qsize
The current queue size (each object in the queue may have different size). |
| Constructor Summary | |
QLogic()
|
|
QLogic(Component host_)
|
|
QLogic(Component host_,
java.lang.String qpid_)
|
|
| Method Summary | |
java.lang.String |
adviceOn(java.lang.Object obj_,
int size_)
Advices the host component for deciding whether or not to drop the (arriving) object. |
void |
dequeueHandler(java.lang.Object obj_,
int size_)
Handles the event of dequeuing the object of the given size. |
void |
dropHandler(java.lang.Object obj_,
int size_)
Handles the event of dropping the object of the given size. |
void |
duplicate(java.lang.Object source_)
Duplicates the content of the source object to this object. |
void |
enqueueHandler(java.lang.Object obj_,
int size_)
Handles the event of enqueuing the object of the given size. |
int |
getCapacity()
Returns the capacity of the queue. |
int |
getCurrentQLength()
Returns the current length of the queue. |
int |
getCurrentQSize()
Returns the current size of the queue. |
Component |
getHost()
|
java.lang.String |
info()
Prints the content (states) of this queue management instance. |
java.lang.String |
info(java.lang.String prefix_)
Prints the content (states) of this queue management instance. |
boolean |
isEmpty()
Returns true if the queue is empty. |
boolean |
isFull()
Returns true if the queue is full. |
void |
reset()
Resets this object to the initial state. |
void |
set(Component host_,
java.lang.String pid_)
|
void |
setCapacity(int capacity_)
Sets the capacity of the queue. |
void |
setHost(Component host_)
|
void |
setQSizePort(java.lang.String pid_)
|
| Methods inherited from class drcl.DrclObj |
clone, toString |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final java.lang.String EVENT_QSIZE
public int capacity
public int qsize
public int qlen
| Constructor Detail |
public QLogic()
public QLogic(Component host_)
public QLogic(Component host_,
java.lang.String qpid_)
| Method Detail |
public void reset()
super.reset() when
overriding this method.
public void duplicate(java.lang.Object source_)
source_.
Subclasses must call super.duplicate() when
overriding this method.
duplicate in interface ObjectDuplicableduplicate in class DrclObjpublic java.lang.String info()
info(null).
public java.lang.String info(java.lang.String prefix_)
prefix_ - prefix of each line in the printout.
public java.lang.String adviceOn(java.lang.Object obj_,
int size_)
public void dropHandler(java.lang.Object obj_,
int size_)
public void enqueueHandler(java.lang.Object obj_,
int size_)
public void dequeueHandler(java.lang.Object obj_,
int size_)
public void setCapacity(int capacity_)
public int getCapacity()
public int getCurrentQSize()
public int getCurrentQLength()
public boolean isFull()
public boolean isEmpty()
public void setHost(Component host_)
public Component getHost()
public void setQSizePort(java.lang.String pid_)
pid_ - ID of the port.
public void set(Component host_,
java.lang.String pid_)
pid_ - ID of the port.
|
DRCL J-Sim API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||