Skip to content
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

Merged
merged 2 commits into from
Dec 17, 2015
Merged

Conversation

andresag01
Copy link

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.

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.
@andresag01
Copy link
Author

@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;
Copy link
Member

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.

Copy link
Author

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.

@rgrover
Copy link
Contributor

rgrover commented Dec 16, 2015

+1

@andresag01
Copy link
Author

@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 const Gap.

@pan-
Copy link
Member

pan- commented Dec 17, 2015

+1

pan- added a commit that referenced this pull request Dec 17, 2015
Add onShutdown to register callbacks
@pan- pan- merged commit 31be779 into ARMmbed:develop Dec 17, 2015
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.

3 participants