A Barrier Processor runs am enqueued message through
several stages, in its own thread, before dequeueing it.
In a diagram:
+-----------------------------------------------+
|Barrierprocessor +------------+ |
| ...................| Worker |... |
| . . +------------+ . |
| . . . . |
put() |+---------+ +------+ +------+ +---------+ | take()
------>|Channel |->|Stage1|->|Stage2|->|Channel |------->
|+---------+ +------+ +------+ +---------+ |
+-----------------------------------------------+
Use a barrier processor if you need to shield stages that are
not thread safe from receiving messages from multiple concurrent
threads. Note a barrier processor may create a big bottleneck in
your system. If this happens, you should consider redesigning
your application so that you can either use multiple
singlethreaded stages of the same type, or change those stages to
be thread-safe. The former is usually the more performant option,
but the latter may be easier (by using synchronization in the
appropriate places in your code).
author: Leo Simons version: $Id: BarrierProcessor.java,v 1.1 2004/03/22 21:20:13 lsimons Exp $ |