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
7933d8e1
Commit
7933d8e1
authored
Jul 11, 2022
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename continuation.hpp into theft_point.hpp
parent
3f3c9f45
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
23 deletions
+51
-23
rt/include/typon/future.hpp
rt/include/typon/future.hpp
+8
-8
rt/include/typon/scheduler.hpp
rt/include/typon/scheduler.hpp
+3
-3
rt/include/typon/span.hpp
rt/include/typon/span.hpp
+4
-4
rt/include/typon/stack.hpp
rt/include/typon/stack.hpp
+8
-8
rt/include/typon/theft_point.hpp
rt/include/typon/theft_point.hpp
+28
-0
No files found.
rt/include/typon/future.hpp
View file @
7933d8e1
...
...
@@ -5,10 +5,10 @@
#include <coroutine>
#include <cstdint>
#include <typon/continuation.hpp>
#include <typon/result.hpp>
#include <typon/scheduler.hpp>
#include <typon/stack.hpp>
#include <typon/theft_point.hpp>
namespace
typon
...
...
@@ -18,7 +18,7 @@ namespace typon
struct
[[
nodiscard
]]
Future
{
struct
promise_type
;
using
u64
=
Continuation
::
u64
;
using
u64
=
TheftPoint
::
u64
;
using
enum
std
::
memory_order
;
...
...
@@ -87,10 +87,10 @@ namespace typon
{
std
::
coroutine_handle
<>
await_suspend
(
std
::
coroutine_handle
<
promise_type
>
coroutine
)
noexcept
{
auto
continuation
=
Scheduler
::
peek
();
auto
theftpoint
=
Scheduler
::
peek
();
if
(
Scheduler
::
pop
())
{
return
continuation
->
_coroutine
;
return
theftpoint
->
_coroutine
;
}
auto
state
=
coroutine
.
promise
().
_state
.
exchange
(
ready
,
acq_rel
);
if
(
state
==
discarded
)
...
...
@@ -118,7 +118,7 @@ namespace typon
{
Future
_future
;
std
::
coroutine_handle
<
promise_type
>
_coroutine
;
Continuation
_continuation
;
TheftPoint
_theftpoint
;
awaitable
(
Future
&&
f
,
std
::
coroutine_handle
<
promise_type
>
c
)
noexcept
:
_future
(
std
::
move
(
f
))
...
...
@@ -132,16 +132,16 @@ namespace typon
auto
await_suspend
(
std
::
coroutine_handle
<>
continuation
)
noexcept
{
_
continuation
.
_coroutine
=
continuation
;
_
theftpoint
.
_coroutine
=
continuation
;
std
::
coroutine_handle
<>
on_stack_handle
=
_coroutine
;
Scheduler
::
push
(
&
(
_
continuation
));
Scheduler
::
push
(
&
(
_
theftpoint
));
return
on_stack_handle
;
}
auto
await_resume
()
noexcept
{
_future
.
_ready
=
!
_
continuation
.
_thefts
;
_future
.
_ready
=
!
_
theftpoint
.
_thefts
;
return
std
::
move
(
_future
);
}
};
...
...
rt/include/typon/scheduler.hpp
View file @
7933d8e1
...
...
@@ -10,12 +10,12 @@
#include <utility>
#include <vector>
#include <typon/continuation.hpp>
#include <typon/event_count.hpp>
#include <typon/garbage_collector.hpp>
#include <typon/pool.hpp>
#include <typon/random.hpp>
#include <typon/stack.hpp>
#include <typon/theft_point.hpp>
namespace
typon
...
...
@@ -58,7 +58,7 @@ namespace typon
get
().
_notifyer
.
notify_one
();
}
static
void
push
(
Continuation
*
task
)
noexcept
static
void
push
(
TheftPoint
*
task
)
noexcept
{
get
().
_stack
[
thread_id
]
->
push
(
task
);
}
...
...
@@ -73,7 +73,7 @@ namespace typon
return
result
;
}
static
Continuation
*
peek
()
noexcept
static
TheftPoint
*
peek
()
noexcept
{
return
get
().
_stack
[
thread_id
]
->
peek
();
}
...
...
rt/include/typon/span.hpp
View file @
7933d8e1
...
...
@@ -9,7 +9,7 @@
#include <limits>
#include <vector>
#include <typon/
continuation
.hpp>
#include <typon/
theft_point
.hpp>
namespace
typon
...
...
@@ -65,9 +65,9 @@ namespace typon
};
struct
Span
:
Continuation
struct
Span
:
TheftPoint
{
using
u64
=
Continuation
::
u64
;
using
u64
=
TheftPoint
::
u64
;
static
constexpr
u64
UMAX
=
std
::
numeric_limits
<
u64
>::
max
();
...
...
@@ -78,7 +78,7 @@ namespace typon
std
::
atomic
<
u64
>
_n
=
UMAX
;
Span
(
std
::
coroutine_handle
<>
coroutine
)
noexcept
:
Continuation
(
coroutine
)
:
TheftPoint
(
coroutine
)
{}
void
resume
()
...
...
rt/include/typon/stack.hpp
View file @
7933d8e1
...
...
@@ -7,8 +7,8 @@
#include <type_traits>
#include <utility>
#include <typon/continuation.hpp>
#include <typon/ring_buffer.hpp>
#include <typon/theft_point.hpp>
namespace
typon
...
...
@@ -16,7 +16,7 @@ namespace typon
struct
Stack
{
using
RingBuffer
=
typon
::
RingBuffer
<
Continuation
*>
;
using
RingBuffer
=
typon
::
RingBuffer
<
TheftPoint
*>
;
using
u64
=
RingBuffer
::
u64
;
using
enum
std
::
memory_order
;
...
...
@@ -39,7 +39,7 @@ namespace typon
delete
_buffer
.
load
(
relaxed
);
}
void
push
(
Continuation
*
x
)
noexcept
void
push
(
TheftPoint
*
x
)
noexcept
{
u64
bottom
=
_bottom
.
load
(
relaxed
);
u64
top
=
_top
.
load
(
acquire
);
...
...
@@ -74,14 +74,14 @@ namespace typon
return
false
;
}
Continuation
*
peek
()
noexcept
TheftPoint
*
peek
()
noexcept
{
u64
bottom
=
_bottom
.
load
(
relaxed
)
-
1
;
RingBuffer
*
buffer
=
_buffer
.
load
(
relaxed
);
return
buffer
->
get
(
bottom
);
}
Continuation
*
steal
()
noexcept
TheftPoint
*
steal
()
noexcept
{
u64
top
=
_top
.
load
(
acquire
);
std
::
atomic_thread_fence
(
seq_cst
);
...
...
@@ -89,7 +89,7 @@ namespace typon
RingBuffer
*
buffer
=
_buffer
.
load
(
consume
);
if
(
top
<
bottom
)
{
Continuation
*
x
=
buffer
->
get
(
top
);
TheftPoint
*
x
=
buffer
->
get
(
top
);
if
(
!
_top
.
compare_exchange_strong
(
top
,
top
+
1
,
seq_cst
,
relaxed
))
{
return
nullptr
;
...
...
@@ -99,12 +99,12 @@ namespace typon
return
nullptr
;
}
Continuation
*
pop_top
()
noexcept
TheftPoint
*
pop_top
()
noexcept
{
u64
top
=
_top
.
load
(
relaxed
);
u64
bottom
=
_bottom
.
load
(
relaxed
);
auto
buffer
=
_buffer
.
load
(
relaxed
);
Continuation
*
x
=
nullptr
;
TheftPoint
*
x
=
nullptr
;
if
(
top
<
bottom
)
{
x
=
buffer
->
get
(
top
);
...
...
rt/include/typon/
continuation
.hpp
→
rt/include/typon/
theft_point
.hpp
View file @
7933d8e1
#ifndef TYPON_
CONTINUATION
_HPP_INCLUDED
#define TYPON_
CONTINUATION
_HPP_INCLUDED
#ifndef TYPON_
THEFT_POINT
_HPP_INCLUDED
#define TYPON_
THEFT_POINT
_HPP_INCLUDED
#include <coroutine>
#include <cstdint>
...
...
@@ -8,16 +8,16 @@
namespace
typon
{
struct
Continuation
struct
TheftPoint
{
using
u64
=
std
::
uint_fast64_t
;
std
::
coroutine_handle
<>
_coroutine
;
u64
_thefts
=
0
;
Continuation
()
noexcept
{}
TheftPoint
()
noexcept
{}
Continuation
(
std
::
coroutine_handle
<>
coroutine
)
noexcept
TheftPoint
(
std
::
coroutine_handle
<>
coroutine
)
noexcept
:
_coroutine
(
coroutine
)
{}
};
...
...
@@ -25,4 +25,4 @@ namespace typon
}
#endif // TYPON_
CONTINUATION
_HPP_INCLUDED
#endif // TYPON_
THEFT_POINT
_HPP_INCLUDED
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