public class ThreadProcessor extends ProcessorAdapter implements java.lang.Runnable
| Modifier and Type | Class and Description |
|---|---|
private static class |
ThreadProcessor.ShutdownEvent
Helper event to stop the internal thread on close.
|
| Modifier and Type | Field and Description |
|---|---|
private Processor |
processor
The internal processor that processes the input events.
|
private java.util.concurrent.BlockingQueue<Event> |
queue
The queue for storing of the incoming events before their processing.
|
private java.lang.Thread |
thread
The thread for this processor.
|
logger| Constructor and Description |
|---|
ThreadProcessor(Processor processor)
Create the object.
|
ThreadProcessor(Processor processor,
boolean daemon,
java.util.concurrent.BlockingQueue<Event> queue)
Create the object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Finish processing of the events and free all allocated resources.
|
(package private) java.lang.String |
getThreadName()
Helper method to get the name of the internally executed thread.
|
Event |
process(Event event)
Process the event.
|
void |
run() |
void |
start()
Building of the processor is finished, prepare it to the events
processing.
|
getNameprivate final java.lang.Thread thread
private final java.util.concurrent.BlockingQueue<Event> queue
private final Processor processor
public ThreadProcessor(Processor processor, boolean daemon, java.util.concurrent.BlockingQueue<Event> queue)
processor - the internal processor that process the input eventsdaemon - the thread is a daemon threadqueue - the queue for storing of the incoming events before their
processingpublic ThreadProcessor(Processor processor)
LinkedBlockingQueue with unlimited length.processor - the internal processor that process the input eventsjava.lang.String getThreadName()
public void start()
throws FsmException
Processorstart in interface Processorstart in class ProcessorAdapterFsmExceptionProcessor.close()public void close()
ProcessorProcessor.close() should be
avoided. The behavior is not defined and may cause unpredictable
behavior, e.g. NullPointerException.close in interface Processorclose in class ProcessorAdapterProcessor.start()public Event process(Event event) throws FsmException
Processorprocess in interface Processorevent - the input eventFsmException - if something failspublic void run()
run in interface java.lang.RunnableCopyright 2013 Michal Turek, AnotherFSM.