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
e64a5f8b
Commit
e64a5f8b
authored
Jun 20, 2022
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scheduler.hpp: Use multiple calls to Scheduler::get()
parent
2ba25c7b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
14 deletions
+10
-14
rt/include/typon/core/scheduler.hpp
rt/include/typon/core/scheduler.hpp
+10
-14
No files found.
rt/include/typon/core/scheduler.hpp
View file @
e64a5f8b
...
...
@@ -36,10 +36,9 @@ namespace typon
static
void
schedule
(
std
::
coroutine_handle
<>
task
)
noexcept
{
Scheduler
&
scheduler
=
get
();
uint
id
=
fdt
::
random
::
random
()
%
scheduler
.
_concurrency
;
scheduler
.
_worker
[
id
].
add
(
new
Deque
(
task
));
scheduler
.
_notifyer
.
notify_one
();
uint
id
=
fdt
::
random
::
random
()
%
get
().
_concurrency
;
get
().
_worker
[
id
].
add
(
new
Deque
(
task
));
get
().
_notifyer
.
notify_one
();
}
static
void
push
(
Continuation
task
)
noexcept
...
...
@@ -49,25 +48,23 @@ namespace typon
static
bool
pop
()
noexcept
{
Scheduler
&
scheduler
=
get
();
Deque
*
deque
=
scheduler
.
_worker
[
thread_id
].
_deque
.
load
();
Deque
*
deque
=
get
().
_worker
[
thread_id
].
_deque
.
load
();
bool
result
=
deque
->
pop
();
if
(
auto
garbage
=
deque
->
reclaim
())
{
scheduler
.
_gc
.
retire
(
garbage
);
get
()
.
_gc
.
retire
(
garbage
);
}
return
result
;
}
static
Deque
*
suspend
(
std
::
coroutine_handle
<>
coroutine
)
noexcept
{
Scheduler
&
scheduler
=
get
();
Worker
&
worker
=
scheduler
.
_worker
[
thread_id
];
Worker
&
worker
=
get
().
_worker
[
thread_id
];
Deque
*
deque
=
worker
.
_deque
.
load
();
worker
.
_deque
.
store
(
nullptr
);
deque
->
suspend
(
coroutine
);
uint
id
=
fdt
::
random
::
random
()
%
scheduler
.
_concurrency
;
scheduler
.
_worker
[
id
].
add
(
deque
);
uint
id
=
fdt
::
random
::
random
()
%
get
()
.
_concurrency
;
get
()
.
_worker
[
id
].
add
(
deque
);
return
deque
;
}
...
...
@@ -76,9 +73,8 @@ namespace typon
auto
state
=
deque
->
_state
.
exchange
(
Deque
::
Resumable
);
if
(
state
==
Deque
::
Empty
)
{
Scheduler
&
scheduler
=
get
();
uint
id
=
fdt
::
random
::
random
()
%
scheduler
.
_concurrency
;
scheduler
.
_worker
[
id
].
add
(
deque
);
uint
id
=
fdt
::
random
::
random
()
%
get
().
_concurrency
;
get
().
_worker
[
id
].
add
(
deque
);
}
get
().
_notifyer
.
notify_one
();
}
...
...
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