Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
athena
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Peter Sherwood
athena
Commits
3519ebd2
Commit
3519ebd2
authored
4 years ago
by
scott snyder
Browse files
Options
Downloads
Patches
Plain Diff
Fix conflict with gtest macro
parent
88287e14
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Control/CxxUtils/CxxUtils/ConcurrentHashmapImpl.h
+29
-26
29 additions, 26 deletions
Control/CxxUtils/CxxUtils/ConcurrentHashmapImpl.h
Control/CxxUtils/CxxUtils/ConcurrentHashmapImpl.icc
+10
-10
10 additions, 10 deletions
Control/CxxUtils/CxxUtils/ConcurrentHashmapImpl.icc
with
39 additions
and
36 deletions
Control/CxxUtils/CxxUtils/ConcurrentHashmapImpl.h
+
29
−
26
View file @
3519ebd2
...
...
@@ -35,7 +35,7 @@ namespace detail {
/// Type used for keys and values --- an unsigned big enough to hold a pointer.
/// Need to have this defined outside of ConcurrentHashmapImpl itself
/// in order to avoid instantiation circularities, as the HASHER and MATCHER
/// in order to avoid instantiation circularities, as the HASHER
_
and MATCHER
_
/// classes will probably want to use it.
using
ConcurrentHashmapVal_t
=
uintptr_t
;
...
...
@@ -130,15 +130,15 @@ private:
* are much more frequent than writes.
*
* Template arguments:
* UPDATER - Object used for memory management; see below.
* This has the same requirements as for ConcurrentRangeMap;
* see there for further details.
* HASHER - Functional to compute a hash value from a key.
* Defaults to std::hash.
* MATCHER - Functional to compare two keys for equality.
* Defaults to std::equal_to.
* NULLVAL - Value of the key to be considered null.
* A key with this value may not be inserted.
* UPDATER
_
- Object used for memory management; see below.
*
This has the same requirements as for ConcurrentRangeMap;
*
see there for further details.
* HASHER
_
- Functional to compute a hash value from a key.
*
Defaults to std::hash.
* MATCHER
_
- Functional to compare two keys for equality.
*
Defaults to std::equal_to.
* NULLVAL
_
-
Value of the key to be considered null.
*
A key with this value may not be inserted.
*
* Implementation notes:
* We use open addressing (see, eg, knuth AOCP 6.4), in which the payloads
...
...
@@ -150,22 +150,25 @@ private:
*
* The implementation here is inspired by the hash maps from ConcurrencyKit
* (http://concurrencykit.org), though the code is all new.
*
* nb. Can't use plain `MATCHER' as a template argument because it collides
* with gtest.
*/
template
<
template
<
class
>
class
UPDATER
,
typename
HASHER
=
std
::
hash
<
uintptr_t
>,
typename
MATCHER
=
std
::
equal_to
<
uintptr_t
>
,
uintptr_t
NULLVAL
=
0
>
template
<
template
<
class
>
class
UPDATER
_
,
typename
HASHER
_
=
std
::
hash
<
uintptr_t
>,
typename
MATCHER
_
=
std
::
equal_to
<
uintptr_t
>
,
uintptr_t
NULLVAL
_
=
0
>
class
ConcurrentHashmapImpl
{
public:
/// Type used for keys and values --- an unsigned big enough to hold a pointer.
using
val_t
=
ConcurrentHashmapVal_t
;
/// Hash object.
using
Hasher_t
=
HASHER
;
using
Hasher_t
=
HASHER
_
;
/// Key match object.
using
Matcher_t
=
MATCHER
;
using
Matcher_t
=
MATCHER
_
;
/// Null key value.
static
constexpr
uintptr_t
nullval
=
NULLVAL
;
static
constexpr
uintptr_t
nullval
=
NULLVAL
_
;
/// Used to represent an invalid table index.
static
constexpr
size_t
INVALID
=
static_cast
<
size_t
>
(
-
1
);
...
...
@@ -217,8 +220,8 @@ private:
* @param matcher Key match object to use.
*/
Table
(
size_t
capacity
,
const
H
ASHER
&
hasher
=
H
ASHER
(),
const
M
ATCHER
&
matcher
=
M
ATCHER
());
const
H
asher_t
&
hasher
=
H
asher_t
(),
const
M
atcher_t
&
matcher
=
M
atcher_t
());
/**
...
...
@@ -291,9 +294,9 @@ private:
/// Number of bits in the mask.
const
size_t
m_maskBits
;
/// The hash object.
const
H
ASHER
&
m_hasher
;
const
H
asher_t
&
m_hasher
;
/// The key match object.
const
M
ATCHER
&
m_matcher
;
const
M
atcher_t
&
m_matcher
;
/// Longest probe needed so far.
std
::
atomic
<
size_t
>
m_longestProbe
;
/// The actual table entries.
...
...
@@ -303,7 +306,7 @@ private:
public
:
/// Updater object.
using
Updater_t
=
UPDATER
<
Table
>
;
using
Updater_t
=
UPDATER
_
<
Table
>
;
/// Context type for the updater.
using
Context_t
=
typename
Updater_t
::
Context_t
;
...
...
@@ -320,8 +323,8 @@ public:
*/
ConcurrentHashmapImpl
(
Updater_t
&&
updater
,
size_t
capacity_in
,
const
H
ASHER
&
hasher
,
const
M
ATCHER
&
matcher
,
const
H
asher_t
&
hasher
,
const
M
atcher_t
&
matcher
,
const
typename
Updater_t
::
Context_t
&
ctx
);
...
...
@@ -549,9 +552,9 @@ private:
/// Updater object managing memory. See above.
Updater_t
m_updater
;
/// The hash object.
const
H
ASHER
m_hasher
;
const
H
asher_t
m_hasher
;
/// The key match object.
const
M
ATCHER
m_matcher
;
const
M
atcher_t
m_matcher
;
/// The current table instance. Must be holding the mutex to access this.
Table
*
m_table
;
/// Number of entries in the map.
...
...
This diff is collapsed.
Click to expand it.
Control/CxxUtils/CxxUtils/ConcurrentHashmapImpl.icc
+
10
−
10
View file @
3519ebd2
...
...
@@ -97,12 +97,12 @@ bool CHMTableIterator<ENTRIES_PER_CACHELINE>::next()
#define T_CHMIMPL \
template <template <class> class UPDATER, \
typename HASHER, \
typename MATCHER, \
uintptr_t NULLVAL>
template <template <class> class UPDATER
_
, \
typename HASHER
_
, \
typename MATCHER
_
, \
uintptr_t NULLVAL
_
>
#define CHMIMPL ConcurrentHashmapImpl<UPDATER, HASHER, MATCHER, NULLVAL>
#define CHMIMPL ConcurrentHashmapImpl<UPDATER
_
, HASHER
_
, MATCHER
_
, NULLVAL
_
>
/**
...
...
@@ -113,8 +113,8 @@ bool CHMTableIterator<ENTRIES_PER_CACHELINE>::next()
*/
T_CHMIMPL
CHMIMPL
::
Table
::
Table
(
size_t
capacity
,
const
H
ASHER
&
hasher
/*= H
ASHER
()*/
,
const
M
ATCHER
&
matcher
/*= M
ATCHER
()*/
)
const
H
asher_t
&
hasher
/*= H
asher_t
()*/
,
const
M
atcher_t
&
matcher
/*= M
atcher_t
()*/
)
:
m_capacity
(
capacity
),
m_maxProbe
(
capacity
/
4
),
m_mask
(
capacity
-
1
),
...
...
@@ -125,7 +125,7 @@ CHMIMPL::Table::Table (size_t capacity,
{
// Clear all the keys.
for
(
size_t
i
=
0
;
i
<
capacity
;
i
++
)
{
m_entries
[
i
].
m_key
=
NULLVAL
;
m_entries
[
i
].
m_key
=
nullval
;
}
}
...
...
@@ -278,8 +278,8 @@ typename CHMIMPL::entry_t& CHMIMPL::Table::entry (size_t offset)
T_CHMIMPL
CHMIMPL
::
ConcurrentHashmapImpl
(
Updater_t
&&
updater
,
size_t
capacity_in
,
const
H
ASHER
&
hasher
,
const
M
ATCHER
&
matcher
,
const
H
asher_t
&
hasher
,
const
M
atcher_t
&
matcher
,
const
typename
Updater_t
::
Context_t
&
ctx
)
:
m_updater
(
std
::
move
(
updater
)),
m_hasher
(
hasher
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment