Skip to content

Added dispatchIfAny and directDispatchIfAny to report whether any listener was invoked - #82

Open
Haititi wants to merge 1 commit into
wqking:masterfrom
Haititi:feature/dispatch-if-any
Open

Haititi wants to merge 1 commit into
wqking:masterfrom
Haititi:feature/dispatch-if-any

Conversation

@Haititi

@Haititi Haititi commented Oct 6, 2026 •

Copy link
Copy Markdown

They are same as dispatch and directDispatch but return true if there is any listener for the event (for HeterEventDispatcher, any listener with the prototype matching the arguments), false if there is no listener or the dispatching is blocked by a mixin. This avoids calling hasAnyListener before dispatch, which looks up the event twice and is not atomic in multi threading.

dispatch and directDispatch keep returning void and now forward to the new functions, so existing code is not affected. Added HeterCallbackList::invokeIfAny for the heter dispatcher. Added unit tests and documents.

@Haititi Haititi changed the title Added dispatchIfAny and directDispatchIfAny to report whether any lis… Added dispatchIfAny and directDispatchIfAny to report whether any listener was invoked Oct 6, 2026
…tener was invoked

They are same as dispatch and directDispatch but return true if there is any listener
for the event (for HeterEventDispatcher, any listener with the prototype matching the
arguments), false if there is no listener or the dispatching is blocked by a mixin.
This avoids calling hasAnyListener before dispatch, which looks up the event twice
and is not atomic in multi threading.

dispatch and directDispatch keep returning void and now forward to the new functions,
so existing code is not affected. Added HeterCallbackList::invokeIfAny for the heter
dispatcher. Added unit tests and documents.
@Haititi
Haititi force-pushed the feature/dispatch-if-any branch from 11fdfe0 to 392fb94 Compare October 6, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant