biz.hammurapi.dispatch
Class QueuingDispatcher
java.lang.Object
biz.hammurapi.dispatch.Dispatcher
biz.hammurapi.dispatch.QueuingDispatcher
public class QueuingDispatcher
- extends Dispatcher
This class puts results to a queue, which is processed by a worker.
An internal thread is used to push jobs to worker or execute jobs if worker is null.
- Author:
- Pavel Vlasov
Field Summary |
protected java.util.LinkedList |
queue
|
Constructor Summary |
QueuingDispatcher(java.util.Collection targets,
biz.hammurapi.util.Worker worker)
Constructor |
Method Summary |
void |
dispatch(java.lang.Object arg)
Puts argument to dispatching queue. |
void |
join()
Blocks until all jobs are processed. |
protected void |
postJobToQueue(java.lang.Runnable foreignJob)
Allows subclasses to post non-dispatching jobs to the queue. |
void |
stop()
Processes all jobs and stops queue processing thread. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
queue
protected java.util.LinkedList queue
QueuingDispatcher
public QueuingDispatcher(java.util.Collection targets,
biz.hammurapi.util.Worker worker)
- Constructor
- Parameters:
targets
- worker
- Worker to delegate dispatching jobs to. Can be null.
postJobToQueue
protected void postJobToQueue(java.lang.Runnable foreignJob)
- Allows subclasses to post non-dispatching jobs to the queue.
- Parameters:
job
-
dispatch
public void dispatch(java.lang.Object arg)
- Puts argument to dispatching queue.
The queue is processed by an internal thread, which posts dispatching jobs to worker or
processes them itself if worker is null.
- Overrides:
dispatch
in class Dispatcher
- Parameters:
arg
- Instance to be dispatched.
join
public void join()
throws java.lang.InterruptedException
- Blocks until all jobs are processed.
- Throws:
java.lang.InterruptedException
stop
public void stop()
throws java.lang.InterruptedException
- Processes all jobs and stops queue processing thread.
- Throws:
java.lang.InterruptedException
Copyright © 2005 Hammurapi Group. All Rights Reserved.