-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add onShutdown to register callbacks #146
Conversation
Add an onShutdown() function to Gap, GattClient, GattServer and SecurityManager. The callbacks are added to a private callback chain in each of the instances. The callbacks will be executed inside each object's reset() function BEFORE the state of the instance is cleared. The developers of the platform-specific implementation must call the parent class' reset() function for the callbacks to be executed. Finally, an onShutdown() function that returns the shutdown callchain is added to allow detaching callbacks.
@LiyouZhou @pan- @rgrover: This PR is related to #141 |
@@ -161,6 +161,9 @@ class Gap { | |||
|
|||
typedef FunctionPointerWithContext<bool> RadioNotificationEventCallback_t; | |||
|
|||
typedef FunctionPointerWithContext<const Gap *> GapShutdownCallback_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that Gap should be const here, the user will want to remove its own callback from the shutdown callback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out. Once the callback is executed it is not removed from the callback chain. In my opinion the best approach is to add code to the reset()
functions in every class clearing the callback chain which would effectively reset state.
+1 |
@rgrover @LiyouZhou @pan-: I have updated the pull request to clear the shutdown callchain after the callbacks are executed. This is in response to @pan- comment about |
+1 |
Add onShutdown to register callbacks
Add an onShutdown() function to Gap, GattClient, GattServer and
SecurityManager. The callbacks are added to a private callback chain in each of
the instances. The callbacks will be executed inside each object's reset()
function BEFORE the state of the instance is cleared. The developers of the
platform-specific implementation must call the parent class' reset() function
for the callbacks to be executed.
Finally, an onShutdown() function that returns the shutdown callchain is added
to allow detaching callbacks.