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

Fix incorrect value_type for concurrent_[unordered_]set::iterator #1010

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

kboyarinov
Copy link
Contributor

Description

Fix an issue in concurrent_set and concurrent_unordered_set - iterator types should be constant for these classes.
Current implementation allows to write the following:

oneapi::tbb::concurrent_set<int> s = {1, 2, 3};
*s.begin() = 42;
// Now s is {42, 2, 3} - elements ordering is broken

The code above can brake elements ordering for ordered containers and place wrong elements into buckets for unordered.

Fixes # - issue number(s) if exists

  • - git commit message contains an appropriate signed-off-by string (see CONTRIBUTING.md for details)

Type of change

Choose one or multiple, leave empty if none of the other choices apply

Add a respective label(s) to PR if you have permissions

  • bug fix - change that fixes an issue
  • new feature - change that adds functionality
  • tests - change in tests
  • infrastructure - change in infrastructure and CI
  • documentation - documentation update

Tests

  • added - required for new features and some bug fixes
  • not needed

Documentation

  • updated in # - add PR number
  • needs to be updated
  • not needed

Breaks backward compatibility

  • Yes
  • No
  • Unknown

Notify the following users

List users with @ to send notifications

Other information

Signed-off-by: kboyarinov <konstantin.boyarinov@intel.com>
Signed-off-by: kboyarinov <konstantin.boyarinov@intel.com>
using const_iterator = skip_list_iterator<list_node_type, const value_type>;
// iterator for ordered sets should be constant to prohibit modification of keys that sorting
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add comment why such approach is used.

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.

None yet

2 participants