Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
FORMUS3IC_LAS3
/
embb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
028a03b5
authored
Aug 25, 2015
by
Danila Klimenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Performance optimizations (UniqueHazardPointer local copy; Tree node leaf/sentinel flags)
parent
11e59de4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
20 deletions
+28
-20
containers_cpp/include/embb/containers/internal/hazard_pointer-inl.h
+8
-2
containers_cpp/include/embb/containers/internal/hazard_pointer.h
+2
-0
containers_cpp/include/embb/containers/internal/lock_free_chromatic_tree-inl.h
+0
-0
containers_cpp/include/embb/containers/lock_free_chromatic_tree.h
+18
-18
No files found.
containers_cpp/include/embb/containers/internal/hazard_pointer-inl.h
View file @
028a03b5
...
@@ -422,12 +422,16 @@ const double embb::containers::internal::HazardPointer<GuardType>::
...
@@ -422,12 +422,16 @@ const double embb::containers::internal::HazardPointer<GuardType>::
template
<
typename
Type
>
template
<
typename
Type
>
UniqueHazardPointer
<
Type
>::
UniqueHazardPointer
<
Type
>::
UniqueHazardPointer
()
UniqueHazardPointer
()
:
hazard_guard_
(
NULL
),
undefined_guard_
(
NULL
),
active_
(
false
)
{}
:
hazard_guard_
(
NULL
),
local_ptr_value_
(
NULL
),
undefined_guard_
(
NULL
),
active_
(
false
)
{}
template
<
typename
Type
>
template
<
typename
Type
>
UniqueHazardPointer
<
Type
>::
UniqueHazardPointer
<
Type
>::
UniqueHazardPointer
(
AtomicTypePtr
&
hazard_guard
,
Type
*
undefined_guard
)
UniqueHazardPointer
(
AtomicTypePtr
&
hazard_guard
,
Type
*
undefined_guard
)
:
hazard_guard_
(
&
hazard_guard
),
:
hazard_guard_
(
&
hazard_guard
),
local_ptr_value_
(
hazard_guard_
->
Load
()),
undefined_guard_
(
undefined_guard
),
undefined_guard_
(
undefined_guard
),
active_
(
LoadGuardedPointer
()
==
undefined_guard_
)
{}
active_
(
LoadGuardedPointer
()
==
undefined_guard_
)
{}
...
@@ -487,6 +491,7 @@ void UniqueHazardPointer<Type>::AdoptHazard(const UniqueHazardPointer& other) {
...
@@ -487,6 +491,7 @@ void UniqueHazardPointer<Type>::AdoptHazard(const UniqueHazardPointer& other) {
template
<
typename
Type
>
template
<
typename
Type
>
void
UniqueHazardPointer
<
Type
>::
Swap
(
UniqueHazardPointer
&
other
)
{
void
UniqueHazardPointer
<
Type
>::
Swap
(
UniqueHazardPointer
&
other
)
{
std
::
swap
(
hazard_guard_
,
other
.
hazard_guard_
);
std
::
swap
(
hazard_guard_
,
other
.
hazard_guard_
);
std
::
swap
(
local_ptr_value_
,
other
.
local_ptr_value_
);
std
::
swap
(
undefined_guard_
,
other
.
undefined_guard_
);
std
::
swap
(
undefined_guard_
,
other
.
undefined_guard_
);
std
::
swap
(
active_
,
other
.
active_
);
std
::
swap
(
active_
,
other
.
active_
);
}
}
...
@@ -517,12 +522,13 @@ void UniqueHazardPointer<Type>::ClearHazard() {
...
@@ -517,12 +522,13 @@ void UniqueHazardPointer<Type>::ClearHazard() {
template
<
typename
Type
>
template
<
typename
Type
>
Type
*
UniqueHazardPointer
<
Type
>::
LoadGuardedPointer
()
const
{
Type
*
UniqueHazardPointer
<
Type
>::
LoadGuardedPointer
()
const
{
return
hazard_guard_
->
Load
()
;
return
local_ptr_value_
;
}
}
template
<
typename
Type
>
template
<
typename
Type
>
void
UniqueHazardPointer
<
Type
>::
StoreGuardedPointer
(
Type
*
ptr
)
{
void
UniqueHazardPointer
<
Type
>::
StoreGuardedPointer
(
Type
*
ptr
)
{
hazard_guard_
->
Store
(
ptr
);
hazard_guard_
->
Store
(
ptr
);
local_ptr_value_
=
ptr
;
}
}
template
<
typename
Type
>
template
<
typename
Type
>
...
...
containers_cpp/include/embb/containers/internal/hazard_pointer.h
View file @
028a03b5
...
@@ -692,6 +692,8 @@ class UniqueHazardPointer {
...
@@ -692,6 +692,8 @@ class UniqueHazardPointer {
* hazardous pointers
* hazardous pointers
*/
*/
AtomicTypePtr
*
hazard_guard_
;
AtomicTypePtr
*
hazard_guard_
;
/** Local copy of the guarded pointer value (used for optimization) */
Type
*
local_ptr_value_
;
/** Dummy value used to clear the hazard guard from any hazards */
/** Dummy value used to clear the hazard guard from any hazards */
Type
*
undefined_guard_
;
Type
*
undefined_guard_
;
/** Flag set to true when the guard is protecting some hazardous pointer */
/** Flag set to true when the guard is protecting some hazardous pointer */
...
...
containers_cpp/include/embb/containers/internal/lock_free_chromatic_tree-inl.h
View file @
028a03b5
This diff is collapsed.
Click to expand it.
containers_cpp/include/embb/containers/lock_free_chromatic_tree.h
View file @
028a03b5
...
@@ -33,6 +33,8 @@
...
@@ -33,6 +33,8 @@
#include <embb/base/c/errors.h>
#include <embb/base/c/errors.h>
#include <embb/base/mutex.h>
#include <embb/base/mutex.h>
#include <embb/containers/internal/hazard_pointer.h>
#include <embb/containers/internal/hazard_pointer.h>
#include <embb/containers/lock_free_tree_value_pool.h>
#include <embb/containers/object_pool.h>
namespace
embb
{
namespace
embb
{
namespace
containers
{
namespace
containers
{
...
@@ -124,6 +126,20 @@ class ChromaticTreeNode {
...
@@ -124,6 +126,20 @@ class ChromaticTreeNode {
Node
*
GetRight
()
const
;
Node
*
GetRight
()
const
;
/**
/**
* Checks if the node is a leaf.
*
* @return \c true if node is a leaf, \c false otherwise
*/
bool
IsLeaf
()
const
;
/**
* Checks if the node is a sentinel.
*
* @return \c true if node is a sentinel, \c false otherwise
*/
bool
IsSentinel
()
const
;
/**
* Tries to replace one of the child pointers that compares equal to
* Tries to replace one of the child pointers that compares equal to
* \c old_child with the \c new_child using an atomic compare-and-swap
* \c old_child with the \c new_child using an atomic compare-and-swap
* operation. If neither left nor right child pointer is pointing to
* operation. If neither left nor right child pointer is pointing to
...
@@ -169,6 +185,8 @@ class ChromaticTreeNode {
...
@@ -169,6 +185,8 @@ class ChromaticTreeNode {
const
Key
key_
;
/**< Stored key. */
const
Key
key_
;
/**< Stored key. */
const
Value
value_
;
/**< Stored value. */
const
Value
value_
;
/**< Stored value. */
const
int
weight_
;
/**< Weight of the node. */
const
int
weight_
;
/**< Weight of the node. */
const
bool
is_leaf_
;
/**< True if node is a leaf. */
const
bool
is_sentinel_
;
/**< True if node is a sentinel. */
AtomicNodePtr
left_
;
/**< Pointer to left child node. */
AtomicNodePtr
left_
;
/**< Pointer to left child node. */
AtomicNodePtr
right_
;
/**< Pointer to right child node. */
AtomicNodePtr
right_
;
/**< Pointer to right child node. */
AtomicFlag
retired_
;
/**< Retired (marked for deletion) flag. */
AtomicFlag
retired_
;
/**< Retired (marked for deletion) flag. */
...
@@ -692,24 +710,6 @@ class ChromaticTree {
...
@@ -692,24 +710,6 @@ class ChromaticTree {
HazardNodePtr
&
grandparent
);
HazardNodePtr
&
grandparent
);
/**
/**
* Checks whether the given node is a leaf.
*
* \param[IN] node Node to be checked
*
* \return \c true if the given node is a leaf, \c false otherwise
*/
bool
IsLeaf
(
const
Node
*
node
)
const
;
/**
* Checks whether the given node is a sentinel node.
*
* \param[IN] node Node to be checked
*
* \return \c true if the given node is a sentinel node, \c false otherwise
*/
bool
IsSentinel
(
const
Node
*
node
)
const
;
/**
* Checks whether the given node has a specified child node.
* Checks whether the given node has a specified child node.
*
*
* \param[IN] parent Parent node
* \param[IN] parent Parent node
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment