public class ConcurrentEventReactor extends EventReactor
EventReactor
to enable multiple worker threads for processing events
concurrently. This assumes that the object with event handlers can deal
with being accessed by multiple threads concurrently.
In all likelihood, spinning up threads when necessary using the single-threaded EventReactor would be an easier and fairly performant alternative to using this class.
Constructor and Description |
---|
ConcurrentEventReactor(java.lang.Object handlerObject,
EventMap eventMap,
int poolSize)
Creates a ConcurrentEventReactor with the default
BasicEventWrapper EventWrapper implementation. |
ConcurrentEventReactor(java.lang.Object handlerObject,
EventWrapper wrapper,
int poolSize)
Creates a ConcurrentEventReactor with a custom EventWrapper
implementation.
|
Modifier and Type | Method and Description |
---|---|
void |
start()
Initializes the event reactor by creating worker threads and having them
block on the event queue.
|
void |
stop()
Gracefully shuts down all the worker threads being maintained by this
event reactor.
|
linkEventHandlers, onConnect, onDisconnect, onMessage, processNextEvent, wrapEvent
public ConcurrentEventReactor(java.lang.Object handlerObject, EventMap eventMap, int poolSize)
BasicEventWrapper
EventWrapper implementation.handlerObject
- an Object instance that contains the implementations
for event handlers, denoted by the EventReactor
annotation.eventMap
- a EventMap implementation that provides a mapping from
integer identification numbers to specific classes that represent an
event.poolSize
- the number of worker threads this concurrent event mapper
should maintain.public ConcurrentEventReactor(java.lang.Object handlerObject, EventWrapper wrapper, int poolSize)
handlerObject
- an Object instance that contains the implementations
for event handlers, denoted by the EventHandler
annotation.wrapper
- A problem-specific EventWrapper
implementation.poolSize
- the number of worker threads this concurrent event mapper
should maintain.