Skip to content

Add desctructor to PwmOut #2116

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

Closed
wants to merge 1 commit into from
Closed

Conversation

LMESTM
Copy link
Contributor

@LMESTM LMESTM commented Jul 7, 2016

Issue #2017
Here's a proposal for review of ~PwmOut implementation

@LMESTM
Copy link
Contributor Author

LMESTM commented Jul 12, 2016

@0xc0170 can you add needed reviewers in cc ?

@0xc0170
Copy link
Contributor

0xc0170 commented Jul 15, 2016

@c1728p9 @geky @bogdanm

Please review. We got in HAL xxx_free(), it is implemented for some platforms, for some just empty (thats another problem to be solved). There's one more PR for SerialBase ctor.

@@ -67,6 +67,10 @@ class PwmOut {
core_util_critical_section_exit();
}

/** To Free up pwm pin.
*/
virtual ~PwmOut();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is dtor virtual ? I don't see any virtual method within this class, it's not intended to be a base class.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seconded.

Also the dtor can be inlined here, removing the need to add PwmOut.cpp. Since the function is just a single call to the c api there is no benefit to declaring the function externally.

Looking at this file, should pwmout_free be in a critical section?

@LMESTM
Copy link
Contributor Author

LMESTM commented Jul 15, 2016

Sure - I inspired from other classes and thought it could be a base class as well ... I'll simplify and make it a change in header file only ... when I'm back

@0xc0170
Copy link
Contributor

0xc0170 commented Jul 21, 2016

Let us know once it's updated

@LMESTM
Copy link
Contributor Author

LMESTM commented Aug 16, 2016

back now: I followed recommendations to move all changes to the header file and put it under critical section. This is now rebased on top of master

@LMESTM
Copy link
Contributor Author

LMESTM commented Aug 16, 2016

@0xc0170 : update done

@LMESTM
Copy link
Contributor Author

LMESTM commented Aug 24, 2016

@0xc0170 - seems there are no conflicts for now

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 24, 2016

Thanks. We left similar comment to SerialBase dtor. This requires further design phase, how to handle destruction of objects that handles resources (peripherals). and what shall we allow/disallow within C++ drivers (copy constructor for instance). We will keep you updated.

@LMESTM
Copy link
Contributor Author

LMESTM commented Aug 24, 2016

Is it really better to keep it like this ?
For now as I see it, for basic usage, low layers resources like pin aren't freed, So if you create an object, delete, create the same new object again - it should fail because the pin is not free. At least such a basic use case can work with the proposed patch (For serial there are many derived class so I understand it's more complex).

@sg-
Copy link
Contributor

sg- commented Sep 8, 2016

Is it really better to keep it like this ?

For now, its better to leave it how it is since there are implication and documentation that also need to be considered.

@theotherjimmy
Copy link
Contributor

Please reopen when unblocked.

@LMESTM
Copy link
Contributor Author

LMESTM commented Jul 18, 2017

well I'm not blocked, relevant issue is still open and valid afaik #3106

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.

5 participants