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
d45dc69d
authored
Feb 23, 2016
by
Marcus Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
containers_cpp: fixed codesonar warnings
parent
4e1ccfe4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletions
+9
-1
containers_cpp/include/embb/containers/internal/lock_free_tree_value_pool-inl.h
+4
-1
containers_cpp/test/hazard_pointer_test.cc
+5
-0
No files found.
containers_cpp/include/embb/containers/internal/lock_free_tree_value_pool-inl.h
View file @
d45dc69d
...
@@ -113,14 +113,17 @@ allocate_rec(int node, Type& element) {
...
@@ -113,14 +113,17 @@ allocate_rec(int node, Type& element) {
int
pool_index
=
NodeIndexToPoolIndex
(
node
);
int
pool_index
=
NodeIndexToPoolIndex
(
node
);
Type
expected
=
pool_
[
pool_index
];
Type
expected
=
pool_
[
pool_index
];
if
(
expected
==
Undefined
)
if
(
expected
==
Undefined
)
{
element
=
Type
();
return
-
1
;
return
-
1
;
}
if
(
pool_
[
pool_index
].
CompareAndSwap
(
expected
,
Undefined
))
{
if
(
pool_
[
pool_index
].
CompareAndSwap
(
expected
,
Undefined
))
{
element
=
expected
;
element
=
expected
;
return
pool_index
;
return
pool_index
;
}
}
element
=
Type
();
return
-
1
;
return
-
1
;
}
}
...
...
containers_cpp/test/hazard_pointer_test.cc
View file @
d45dc69d
...
@@ -144,6 +144,7 @@ void HazardPointerTest::HazardPointerTest1ThreadMethod() {
...
@@ -144,6 +144,7 @@ void HazardPointerTest::HazardPointerTest1ThreadMethod() {
for
(
int
i
=
0
;
i
!=
n_elements_per_thread_
;
++
i
)
{
for
(
int
i
=
0
;
i
!=
n_elements_per_thread_
;
++
i
)
{
embb
::
base
::
Atomic
<
int
>*
allocated_object
=
object_pool_
->
Allocate
(
0
);
embb
::
base
::
Atomic
<
int
>*
allocated_object
=
object_pool_
->
Allocate
(
0
);
PT_ASSERT
(
NULL
!=
allocated_object
);
hazard_pointer_
->
Guard
(
0
,
allocated_object
);
hazard_pointer_
->
Guard
(
0
,
allocated_object
);
...
@@ -248,6 +249,7 @@ void HazardPointerTest2::HazardPointerTest2Master() {
...
@@ -248,6 +249,7 @@ void HazardPointerTest2::HazardPointerTest2Master() {
// while the hazard pointer guard array is not full
// while the hazard pointer guard array is not full
int
**
allocatedLocal
=
static_cast
<
int
**>
(
int
**
allocatedLocal
=
static_cast
<
int
**>
(
embb
::
base
::
Allocation
::
Allocate
(
sizeof
(
int
*
)
*
guaranteed_capacity_pool_
));
embb
::
base
::
Allocation
::
Allocate
(
sizeof
(
int
*
)
*
guaranteed_capacity_pool_
));
PT_ASSERT
(
NULL
!=
allocatedLocal
);
bool
full
=
false
;
bool
full
=
false
;
while
(
!
full
)
{
while
(
!
full
)
{
...
@@ -295,16 +297,19 @@ void HazardPointerTest2::HazardPointerTest2Pre() {
...
@@ -295,16 +297,19 @@ void HazardPointerTest2::HazardPointerTest2Pre() {
// first the test pool has to be created
// first the test pool has to be created
test_pool_
=
embb
::
base
::
Allocation
::
New
<
IntObjectTestPool
>
test_pool_
=
embb
::
base
::
Allocation
::
New
<
IntObjectTestPool
>
(
pool_size_using_hazard_pointer_
);
(
pool_size_using_hazard_pointer_
);
PT_ASSERT
(
NULL
!=
test_pool_
);
// after the pool has been created, we create the hp class
// after the pool has been created, we create the hp class
hazard_pointer_
=
embb
::
base
::
Allocation
::
New
<
hazard_pointer_
=
embb
::
base
::
Allocation
::
New
<
embb
::
containers
::
internal
::
HazardPointer
<
int
*>
>
embb
::
containers
::
internal
::
HazardPointer
<
int
*>
>
(
delete_pointer_callback_
,
static_cast
<
int
*>
(
NULL
),
(
delete_pointer_callback_
,
static_cast
<
int
*>
(
NULL
),
static_cast
<
int
>
(
guards_per_phread_count_
),
n_threads
);
static_cast
<
int
>
(
guards_per_phread_count_
),
n_threads
);
PT_ASSERT
(
NULL
!=
hazard_pointer_
);
shared_guarded_
=
static_cast
<
embb
::
base
::
Atomic
<
int
*>*>
(
shared_guarded_
=
static_cast
<
embb
::
base
::
Atomic
<
int
*>*>
(
embb
::
base
::
Allocation
::
Allocate
(
sizeof
(
embb
::
base
::
Atomic
<
int
*>
)
*
embb
::
base
::
Allocation
::
Allocate
(
sizeof
(
embb
::
base
::
Atomic
<
int
*>
)
*
guaranteed_capacity_pool_
));
guaranteed_capacity_pool_
));
PT_ASSERT
(
NULL
!=
shared_guarded_
);
for
(
unsigned
int
i
=
0
;
i
!=
guaranteed_capacity_pool_
;
++
i
)
{
for
(
unsigned
int
i
=
0
;
i
!=
guaranteed_capacity_pool_
;
++
i
)
{
// in-place new for each array cell
// in-place new for each array cell
...
...
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