|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.almendra.commons.threads.ActiveObject
org.almendra.commons.threads.ActiveSchedulingObject
public abstract class ActiveSchedulingObject
Defines an active object that consumes items provided by some producer
object and processes them as long as the list of items to be processed is
not empty. If it becomes empty the ActiveSchedulingObject
falls asleep till a new item has been added to the list.
Field Summary | |
---|---|
protected EDU.oswego.cs.dl.util.concurrent.Semaphore |
available
Lock used to synchronize access to the queue . |
protected boolean |
executing
Answer whether is currently executing an object. |
protected IQueue |
queue
Queue that hold the items to be processed. |
Fields inherited from class org.almendra.commons.threads.ActiveObject |
---|
activeLock, isActive, name, priority, thread, verbose, waiting |
Constructor Summary | |
---|---|
protected |
ActiveSchedulingObject()
Creates a new ActiveSchedulingObject object. |
|
ActiveSchedulingObject(IQueue queue)
Creates a new ActiveSchedulingObject object. |
|
ActiveSchedulingObject(IQueue queue,
boolean verbose)
Creates a new ActiveSchedulingObject object. |
|
ActiveSchedulingObject(IQueue queue,
boolean verbose,
int priority)
Creates a new ActiveSchedulingObject object. |
Method Summary | |
---|---|
void |
add(IExecutable executable)
Adds another item to the queue of items to be processed. |
long |
available()
|
protected void |
doActivity()
Constantly called by the superclass as long as the active object is active. |
protected void |
executableAdded(IExecutable executable)
Called whentever a new item has been added to the queue . |
protected void |
executableRemoved(IExecutable executable)
|
protected abstract void |
execute(IExecutable executable)
Called to process the next item from the queue . |
protected void |
executePrimary(IExecutable executable)
Called to process the next item from the queue . |
protected void |
finishedExecution(IExecutable executable)
|
protected IExecutable |
getNext()
Return the next item of the queue to be processed. |
protected IExecutable |
getNextPrim()
|
long |
getQueueSize()
|
boolean |
hasNext()
|
boolean |
isIdle()
|
protected void |
messageResuming()
|
protected void |
messageSuspending()
|
java.lang.Object |
remove(IExecutable executable)
Remove an item from the queue . |
protected void |
resuming()
|
protected void |
startingExecution(IExecutable executable)
|
protected void |
suspending()
|
Methods inherited from class org.almendra.commons.threads.ActiveObject |
---|
getName, getPriority, isActive, isDaemon, isVerbose, messageStarting, messageStopping, run, setActive, setName, setPriority, setVerbose, start, stop |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected IQueue queue
protected EDU.oswego.cs.dl.util.concurrent.Semaphore available
queue
.
protected volatile boolean executing
Constructor Detail |
---|
protected ActiveSchedulingObject()
ActiveSchedulingObject
object. Declared
protected to enforce the use of the public constructors by objects that
are not subclasses. The public constructors guarantee propper
initialization with default values. Subclasses that want to set other
user-defined values need to make sure themselves that the object is
initialized propperly.
public ActiveSchedulingObject(IQueue queue)
ActiveSchedulingObject
object.
queue
- the queue that holds items to be processedpublic ActiveSchedulingObject(IQueue queue, boolean verbose)
ActiveSchedulingObject
object.
queue
- the queue that holds items to be processedverbose
- defines wether trace information is written to the consolepublic ActiveSchedulingObject(IQueue queue, boolean verbose, int priority)
ActiveSchedulingObject
object.
queue
- the queue that holds items to be processedverbose
- defines wether trace information is written to the consolepriority
- the priority of the thread the active will run inMethod Detail |
---|
protected void doActivity()
ActiveSchedulingObject
items to be
processed are constantly picked from queue
as long as
this queue
is not empty. Otherwise the active object
falls asleep and wakes up when a new item has been added.
doActivity
in class ActiveObject
org.almendra.commons.cas.scheduling.ActiveObject#doActivity()
protected abstract void execute(IExecutable executable)
queue
. Must be
implemented in subclasses as appropriate.
next
- protected void executePrimary(IExecutable executable)
queue
.
next
- the next item from the list to be processedprotected void finishedExecution(IExecutable executable)
next
- protected void startingExecution(IExecutable executable)
next
- public void add(IExecutable executable)
queue
of items to be processed.
Calls objectAdded()
to notify instances of subclasses
that an item has been added to the item list.
object
- protected void executableAdded(IExecutable executable)
queue
.
May be redefined in subclasses as appropriate.
public java.lang.Object remove(IExecutable executable)
queue
.
object
- the object to be removed
protected void executableRemoved(IExecutable executable)
protected IExecutable getNext()
queue
to be processed. Blocks
if queue
is empty.
queue
or null but only if
the active object was stoppedprotected void resuming()
protected void messageResuming()
protected void suspending()
protected void messageSuspending()
public boolean hasNext()
public long available()
protected IExecutable getNextPrim()
public boolean isIdle()
public long getQueueSize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |