Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
cython-plus
typon
Commits
5e078979
Commit
5e078979
authored
May 06, 2022
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Invert top and bottom back in deque.hpp
parent
5369a945
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
20 deletions
+20
-20
rt/include/typon/deque.hpp
rt/include/typon/deque.hpp
+20
-20
No files found.
rt/include/typon/deque.hpp
View file @
5e078979
...
...
@@ -144,57 +144,57 @@ namespace typon
void
push
(
T
x
)
noexcept
{
u64
t
=
_top
.
load
(
relaxed
);
u64
b
=
_bottom
.
load
(
acquire
);
u64
bottom
=
_bottom
.
load
(
relaxed
);
u64
top
=
_top
.
load
(
acquire
);
Array
*
array
=
_array
.
load
(
relaxed
);
if
(
t
-
b
>
array
->
capacity
()
-
1
)
if
(
bottom
-
top
>
array
->
capacity
()
-
1
)
{
array
=
array
->
grow
(
b
,
t
);
array
=
array
->
grow
(
top
,
bottom
);
_array
.
store
(
array
);
}
array
->
put
(
t
,
x
);
array
->
put
(
bottom
,
x
);
std
::
atomic_thread_fence
(
release
);
_
top
.
store
(
t
+
1
,
relaxed
);
_
bottom
.
store
(
bottom
+
1
,
relaxed
);
}
Optional
<
T
>
pop
()
noexcept
{
u64
t
=
_top
.
load
(
relaxed
)
-
1
;
u64
bottom
=
_bottom
.
load
(
relaxed
)
-
1
;
Array
*
array
=
_array
.
load
(
relaxed
);
_
top
.
store
(
t
,
relaxed
);
_
bottom
.
store
(
bottom
,
relaxed
);
std
::
atomic_thread_fence
(
seq_cst
);
u64
b
=
_bottom
.
load
(
relaxed
);
u64
top
=
_top
.
load
(
relaxed
);
Optional
<
T
>
x
{};
if
(
b
<=
t
)
if
(
top
<=
bottom
)
{
x
=
array
->
get
(
t
);
if
(
b
==
t
)
x
=
array
->
get
(
bottom
);
if
(
top
==
bottom
)
{
if
(
!
_
bottom
.
compare_exchange_strong
(
b
,
b
+
1
,
seq_cst
,
relaxed
))
if
(
!
_
top
.
compare_exchange_strong
(
top
,
top
+
1
,
seq_cst
,
relaxed
))
{
x
=
{};
}
_
top
.
store
(
t
+
1
,
relaxed
);
_
bottom
.
store
(
bottom
+
1
,
relaxed
);
}
}
else
{
_
top
.
store
(
t
+
1
,
relaxed
);
_
bottom
.
store
(
bottom
+
1
,
relaxed
);
}
return
x
;
}
Optional
<
T
>
steal
()
noexcept
{
u64
b
=
_bottom
.
load
(
acquire
);
u64
top
=
_top
.
load
(
acquire
);
std
::
atomic_thread_fence
(
seq_cst
);
u64
t
=
_top
.
load
(
acquire
);
u64
bottom
=
_bottom
.
load
(
acquire
);
Optional
<
T
>
x
{};
if
(
b
<
t
)
if
(
top
<
bottom
)
{
Array
*
array
=
_array
.
load
(
consume
);
x
=
array
->
get
(
b
);
if
(
!
_
bottom
.
compare_exchange_strong
(
b
,
b
+
1
,
seq_cst
,
relaxed
))
x
=
array
->
get
(
top
);
if
(
!
_
top
.
compare_exchange_strong
(
top
,
top
+
1
,
seq_cst
,
relaxed
))
{
return
{
Optional
<
T
>::
abort
};
}
...
...
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