concurrent_hash_map.cpp
Go to the documentation of this file.
/*
Copyright (c) 2005-2020 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "tbb/concurrent_hash_map.h"
namespace tbb {
namespace internal {
#if !TBB_NO_LEGACY
struct hash_map_segment_base {
typedef spin_rw_mutex segment_mutex_t;
typedef size_t hashcode_t;
static const size_t n_segment_bits = 6;
static const size_t max_physical_size = size_t(1)<<(8*sizeof(hashcode_t)-n_segment_bits);
segment_mutex_t my_mutex;
// Number of nodes
atomic<size_t> my_logical_size;
// Size of chains
size_t my_physical_size;
bool __TBB_EXPORTED_METHOD internal_grow_predicate() const;
};
bool hash_map_segment_base::internal_grow_predicate() const {
// Intel(R) Thread Checker considers the following reads to be races, so we hide them in the
// library so that Intel(R) Thread Checker will ignore them. The reads are used in a double-check
// context, so the program is nonetheless correct despite the race.
return my_logical_size >= my_physical_size && my_physical_size < max_physical_size;
}
#endif
} // namespace internal
} // namespace tbb
internal
Definition: _flow_graph_async_msg_impl.h:24
tbb::internal::hash_map_segment_base::hashcode_t
size_t hashcode_t
Type of a hash code.
Definition: concurrent_hash_map.cpp:26
tbb
The graph class.
Definition: serial/tbb/parallel_for.h:46
tbb::internal::hash_map_segment_base::segment_mutex_t
spin_rw_mutex segment_mutex_t
Definition: concurrent_hash_map.cpp:24
tbb::internal::hash_map_segment_base::max_physical_size
static const size_t max_physical_size
Maximum size of array of chains.
Definition: concurrent_hash_map.cpp:30
tbb::spin_rw_mutex_v3
Fast, unfair, spinning reader-writer lock with backoff and writer-preference.
Definition: spin_rw_mutex.h:38
concurrent_hash_map.h
tbb::internal::hash_map_segment_base::my_mutex
segment_mutex_t my_mutex
Mutex that protects this segment.
Definition: concurrent_hash_map.cpp:32
tbb::internal::hash_map_segment_base::internal_grow_predicate
bool __TBB_EXPORTED_METHOD internal_grow_predicate() const
True if my_logical_size>=my_physical_size.
Definition: concurrent_hash_map.cpp:43
tbb::internal::hash_map_segment_base
Definition: concurrent_hash_map.cpp:23
tbb::internal::hash_map_segment_base::n_segment_bits
static const size_t n_segment_bits
Log2 of n_segment.
Definition: concurrent_hash_map.cpp:28
tbb::internal::hash_map_segment_base::my_logical_size
atomic< size_t > my_logical_size
Definition: concurrent_hash_map.cpp:34
tbb::internal::hash_map_segment_base::my_physical_size
size_t my_physical_size
Definition: concurrent_hash_map.cpp:37
__TBB_EXPORTED_METHOD
#define __TBB_EXPORTED_METHOD
Definition: tbb_stddef.h:98

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.