T - The type of events the AsyncEvents will process.public class AsyncEvents<T extends AsyncEvent> extends Object implements AsyncEventSender<T>, Runnable
AsyncEvents is a mechanism for queueing up events to be processed asynchronously in a background thread.
The AsyncEvents object implements Runnable, so it can be passed to a thread pool, or given to a
dedicated thread. The runnable will then occupy a thread and dedicate it to background processing of events, until
the AsyncEvents is shutdown().
If events are sent to an AsyncEvents that has been shut down, then those events will be processed in the
foreground as a fall-back.
Note, however, that no events are processed until the background thread is started.
The AsyncEvents is given a Consumer of the specified event type upon construction, and will use it
for doing the actual processing of events once they have been collected.| Modifier and Type | Class and Description |
|---|---|
static interface |
AsyncEvents.Monitor |
| Constructor and Description |
|---|
AsyncEvents(Consumer<T> eventConsumer,
AsyncEvents.Monitor monitor)
Construct a new
AsyncEvents instance, that will use the given consumer to process the events. |
| Modifier and Type | Method and Description |
|---|---|
void |
awaitStartup() |
void |
awaitTermination() |
void |
run() |
void |
send(T event)
Send the given event to a background thread for processing.
|
void |
shutdown()
Initiate the shut down process of this
AsyncEvents instance. |
public AsyncEvents(Consumer<T> eventConsumer, AsyncEvents.Monitor monitor)
AsyncEvents instance, that will use the given consumer to process the events.eventConsumer - The Consumer used for processing the events that are sent in.public void send(T event)
AsyncEventSendersend in interface AsyncEventSender<T extends AsyncEvent>event - The event that needs to be processed in the background.public void shutdown()
AsyncEvents instance.
This call does not block or otherwise wait for the background thread to terminate.public void awaitStartup()
public void awaitTermination()
throws InterruptedException
InterruptedExceptionCopyright © 2002–2017 The Neo4j Graph Database Project. All rights reserved.