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

Changed memberproc to FUNCTOR in Learning the code-Threading page #4832

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Nickmacd88
Copy link

@Nickmacd88 Nickmacd88 commented Dec 25, 2022

The example for registering a timer callback used a deprecated function called memberproc(). I spent multiple days trying to successfully register a callback before I realized that FUNCTOR is the new and updated way to wrap functions. This update will help streamline newcomers into development.

This addresses issue 1339
#1339

@Hwurzburg
Copy link
Contributor

@peterbarker review please

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops - I guess this shows just how badly out-of-date documentation can get, and how much it can hurt when it does. Sorry to hear about your lost time :-/

I figure we just swipe a line of code from the current codebase that (presumably) works, which is my suggestion here.

@@ -42,10 +42,10 @@ hal.scheduler->register_timer_process() like this:

::

hal.scheduler->register_timer_process(AP_HAL_MEMBERPROC(&AP_Baro_MS5611::_update));
hal.scheduler->register_timer_process(FUNCTOR(&AP_Baro_MS5611::_update));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hal.scheduler->register_timer_process(FUNCTOR(&AP_Baro_MS5611::_update));
hal.scheduler->register_timer_process(FUNCTOR_BIND_MEMBER(&AP_Camera_Backend::feedback_pin_timer, void))


that particular example is from the MS5611 barometer driver. The
AP_HAL_MEMBERPROC() macro provides a way to encapsulate a C++ member
FUNCTOR() macro provides a way to encapsulate a C++ member
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FUNCTOR() macro provides a way to encapsulate a C++ member
FUNCTOR_BIND() macro provides a way to encapsulate a C++ member

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