You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhance alwaysCancelling listener awareness in invoker optimisation strategy (#82)
If the event is cancellable but all listeners are consumers, the invoker optimisation strategy would previously bail out to using the wrapped predicates if alwaysCancelling listeners were present.
Now, alwaysCancelling listeners are properly accounted for in this case, combining the benefits of eliminating non-monitoring listeners after them with also unwrapping to branchless consumer calls in the built invoker.
// ...so annoyingly, we need to duplicate the code of createInvoker() here, but with a different primitive return type (boolean instead of void)
195
195
// Maybe JEP 402 can save us from this workaround in the future? https://openjdk.java.net/jeps/402
196
196
197
-
// Todo: [EB][Invoker] Support alwaysCancelling listeners in cancellation check-free Consumer invokers
198
-
if (listeners.stream().map(EventListenerImpl.WrappedConsumerListener.class::cast).noneMatch(EventListenerImpl.WrappedConsumerListener::alwaysCancelling))
* Same as {@link #createInvokerFromUnwrapped(List)} but returns a {@link Predicate} instead of a {@link Consumer}.
252
255
* <p>See the code comments inside {@link #createCancellableInvoker(List)} for an explainer as to why this exists.</p>
256
+
* <p>Also see {@link EventListenerImpl.WrappedConsumerListener#wrap(boolean, Consumer)} for an explainer as to why capturing the return value is avoided.</p>
0 commit comments