Skip to content
This repository has been archived by the owner on Aug 19, 2021. It is now read-only.

Add callback operations to event class #17

Merged
merged 1 commit into from
Sep 24, 2016
Merged

Add callback operations to event class #17

merged 1 commit into from
Sep 24, 2016

Conversation

geky
Copy link
Contributor

@geky geky commented Sep 23, 2016

This adds a C++ style function API that allows the event class to be easily passed as an argument to existing callback based APIs:

void Event<void(args...)>::call(args...)
void Event<void(args...)>::operator()(args...)
static void Event<void(args...)>::thunk(void *, args...)

The previous discussion on this subject can be found here: #15

In reviewing the pr, don't think there are problems with introducing the callable interface. This design is compatible with passing function objects by both reference and by value, and adds convenient integration with existing C and C++ callback APIs without creating a special case for mbed OS.

There is a concern that this interface would encourage users to use the unclear event() syntax. But this can be discouraged through documentation.

cc @pan-

This adds a C++ style function API that allows the event
class to be easily passed as an argument to existing callback
based APIs.

Added functions:
void Event<void(args...)>::call(args...)
void Event<void(args...)>::operator()(args...)
static void Event<void(args...)>::thunk(void *, args...)
@geky
Copy link
Contributor Author

geky commented Sep 24, 2016

Given the experimental nature of this repository, I'm going to go ahead and merge this pr. We can deprecate the callback operations at a later version if we find them to be impractical.

@geky geky merged commit 5015222 into master Sep 24, 2016
@geky geky deleted the event-callable branch September 24, 2016 04:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant