Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon-concurrency
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xavier Thompson
typon-concurrency
Commits
d7cda810
Commit
d7cda810
authored
May 16, 2022
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve ring_buffer.hpp
parent
a3f4452a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
5 deletions
+4
-5
rt/include/typon/fundamental/ring_buffer.hpp
rt/include/typon/fundamental/ring_buffer.hpp
+4
-5
No files found.
rt/include/typon/fundamental/ring_buffer.hpp
View file @
d7cda810
...
...
@@ -18,14 +18,12 @@ namespace typon::fdt::lock_free
using
enum
std
::
memory_order
;
const
u8
_bits
;
const
u64
_mask
;
ring_buffer
*
_next
;
std
::
atomic
<
T
>
*
const
_array
;
ring_buffer
(
u8
bits
,
ring_buffer
*
next
=
nullptr
)
noexcept
:
_bits
(
bits
)
,
_mask
(
this
->
capacity
()
-
1
)
:
_mask
((
u64
(
1
)
<<
bits
)
-
1
)
,
_next
(
next
)
,
_array
(
new
std
::
atomic
<
T
>
[
this
->
capacity
()])
{}
...
...
@@ -41,7 +39,7 @@ namespace typon::fdt::lock_free
u64
capacity
()
noexcept
{
return
u64
(
1
)
<<
_bits
;
return
_mask
+
1
;
}
void
put
(
u64
index
,
T
object
)
noexcept
...
...
@@ -65,7 +63,8 @@ namespace typon::fdt::lock_free
ring_buffer
*
grow
(
u64
start
,
u64
end
)
noexcept
{
return
fill
(
new
ring_buffer
(
_bits
+
1
,
this
),
start
,
end
);
auto
buffer
=
new
ring_buffer
(
std
::
countr_one
(
_mask
)
+
1
,
this
);
return
fill
(
buffer
,
start
,
end
);
}
ring_buffer
*
shrink
(
u64
start
,
u64
end
)
noexcept
...
...
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