Community
cancel
Showing results for 
Search instead for 
Did you mean: 
nash635
Beginner
204 Views

unsafe_bucket_size in concurrent_unordered_base is not const?

Hi,

I'm reading the source code of the concurrent_unordered_map, and found it's interface  unsafe_bucket_size is designed with non-const function, 

so just curious is this by design? i guess if some body invoke this method in a const method, the compiler will not allow that.

https://github.com/intel/tbb/blob/tbb_2020/include/tbb/internal/_concurrent_unordered_impl.h

 

// Bucket interface - for debugging
    size_type unsafe_bucket_count() const {
        return my_number_of_buckets;
    }

    size_type unsafe_max_bucket_count() const {
        return segment_size(pointers_per_table-1);
    }

    size_type unsafe_bucket_size(size_type bucket) { // ====> non const?
        size_type item_count = 0;
        if (is_initialized(bucket)) {
            raw_iterator it = get_bucket(bucket);
            ++it;
            for (; it != my_solist.raw_end() && !it.get_node_ptr()->is_dummy(); ++it)
                ++item_count;
        }
        return item_count;
    }

    size_type unsafe_bucket(const key_type& key) const {
        sokey_t order_key = (sokey_t) my_hash_compare(key);
        size_type bucket = order_key % my_number_of_buckets;
        return bucket;
    }

 

0 Kudos
2 Replies
Alina_S_Intel
Employee
111 Views

Sorry for the delayed response.

unsafe_bucket_size is const in oneTBB so the issue is fixed in the latest release:

https://github.com/oneapi-src/oneTBB/blob/9e15720bc7744f85dff611d34d65e9099e077da4/include/oneapi/tb...


Alina_S_Intel
Employee
102 Views

We will no longer respond to this thread.  

If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.

Thanks,


Reply