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

[threads] remove const constructor from C(Exclusive|Shared|Single)Lock #14180

Merged
merged 3 commits into from
Jul 16, 2018

Conversation

Rechi
Copy link
Member

@Rechi Rechi commented Jul 14, 2018

Description

Instead of casting constness away, mark the lock variables mutable if they are used in const functions.

Motivation and Context

Although casting away the constness of CCriticalSection is allowed in this cases (as the variables aren't declared as const), it still is a hack.

How Has This Been Tested?

compiled for android, ios, linux, osx and windows

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • None of the above (please explain below)

Checklist:

  • My code follows the Code Guidelines of this project
  • My change requires a change to the documentation, either Doxygen or wiki
  • I have updated the documentation accordingly
  • I have read the Contributing document
  • I have added tests to cover my change
  • All new and existing tests passed

@Rechi Rechi added Type: Improvement non-breaking change which improves existing functionality v18 Leia labels Jul 14, 2018
@Rechi Rechi requested a review from FernetMenta July 14, 2018 08:30
@Rechi Rechi added this to the Leia 18.0-alpha3 milestone Jul 16, 2018
@Rechi Rechi merged commit bcb24de into xbmc:master Jul 16, 2018
@Rechi Rechi deleted the lockConstructor branch July 16, 2018 07:30
Copy link
Member

@ksooo ksooo left a comment

Choose a reason for hiding this comment

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

Hmm, seems you made a lot of (all?) critical sections members mutable, but where are all the const_casts you wanted to eliminate?

@@ -1038,7 +1038,7 @@ void CGUIWindow::SetProperty(const std::string &strKey, const CVariant &value)

CVariant CGUIWindow::GetProperty(const std::string &strKey) const
{
CSingleLock lock(*this);
CSingleLock lock(const_cast<CGUIWindow&>(*this));

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Improvement non-breaking change which improves existing functionality v18 Leia
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants