13
0
geforkt von Mirrors/Velocity

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.
Dieser Commit ist enthalten in:
Andrew Steinborn 2019-05-16 17:09:31 -04:00
Ursprung 9e6e1856e6
Commit 3ec67a7d4d

Datei anzeigen

@ -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()) {