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
234e5684
Commit
234e5684
authored
Jun 20, 2022
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Scheduler::suspend
parent
2037fb43
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
rt/include/typon/core/scheduler.hpp
rt/include/typon/core/scheduler.hpp
+2
-4
rt/include/typon/core/worker.hpp
rt/include/typon/core/worker.hpp
+9
-0
No files found.
rt/include/typon/core/scheduler.hpp
View file @
234e5684
...
@@ -57,12 +57,10 @@ namespace typon
...
@@ -57,12 +57,10 @@ namespace typon
return
result
;
return
result
;
}
}
static
Deque
*
suspend
(
std
::
coroutine_handle
<>
coroutine
)
noexcept
static
auto
suspend
(
std
::
coroutine_handle
<>
coroutine
)
noexcept
{
{
Worker
&
worker
=
get
().
_worker
[
thread_id
];
Worker
&
worker
=
get
().
_worker
[
thread_id
];
Deque
*
deque
=
worker
.
_deque
.
load
();
auto
deque
=
worker
.
suspend
(
coroutine
);
worker
.
_deque
.
store
(
nullptr
);
deque
->
suspend
(
coroutine
);
uint
id
=
fdt
::
random
::
random
()
%
get
().
_concurrency
;
uint
id
=
fdt
::
random
::
random
()
%
get
().
_concurrency
;
get
().
_worker
[
id
].
add
(
deque
);
get
().
_worker
[
id
].
add
(
deque
);
return
deque
;
return
deque
;
...
...
rt/include/typon/core/worker.hpp
View file @
234e5684
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#define TYPON_CORE_WORKER_HPP_INCLUDED
#define TYPON_CORE_WORKER_HPP_INCLUDED
#include <atomic>
#include <atomic>
#include <coroutine>
#include <mutex>
#include <mutex>
#include <type_traits>
#include <type_traits>
#include <utility>
#include <utility>
...
@@ -60,6 +61,14 @@ namespace typon
...
@@ -60,6 +61,14 @@ namespace typon
}
}
}
}
auto
suspend
(
std
::
coroutine_handle
<>
coroutine
)
noexcept
{
auto
deque
=
_deque
.
load
();
_deque
.
store
(
nullptr
);
deque
->
suspend
(
coroutine
);
return
deque
;
}
void
resume
(
Work
&
work
)
noexcept
void
resume
(
Work
&
work
)
noexcept
{
{
auto
deque
=
_deque
.
load
();
auto
deque
=
_deque
.
load
();
...
...
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