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
386b5186
Commit
386b5186
authored
Jun 20, 2022
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Scheduler::suspend
parent
b4d6a91a
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 @
386b5186
...
@@ -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 @
386b5186
...
@@ -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