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.
|
getName
private 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
Processor
start
in interface Processor
start
in class ProcessorAdapter
FsmException
Processor.close()
public void close()
Processor
Processor.close()
should be
avoided. The behavior is not defined and may cause unpredictable
behavior, e.g. NullPointerException
.close
in interface Processor
close
in class ProcessorAdapter
Processor.start()
public Event process(Event event) throws FsmException
Processor
process
in interface Processor
event
- the input eventFsmException
- if something failspublic void run()
run
in interface java.lang.Runnable
Copyright 2013 Michal Turek, AnotherFSM.