Optimize VelocityEventManager#fireAndForget()
There isn't a need to create a CompletableFuture when firing an event and we do not want to know when it is completed.
This commit is contained in:
@@ -118,6 +118,18 @@ public class VelocityEventManager implements EventManager {
|
||||
return eventFuture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireAndForget(Object event) {
|
||||
if (event == null) {
|
||||
throw new NullPointerException("event");
|
||||
}
|
||||
if (!bus.hasSubscribers(event.getClass())) {
|
||||
// Optimization: nobody's listening.
|
||||
return;
|
||||
}
|
||||
service.execute(() -> fireEvent(event));
|
||||
}
|
||||
|
||||
private void fireEvent(Object event) {
|
||||
PostResult result = bus.post(event);
|
||||
if (!result.exceptions().isEmpty()) {
|
||||
|
Reference in New Issue
Block a user