Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
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
Operations
Operations
Metrics
Environments
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
cpp-libs
Actor Framework
Commits
14ab6004
Commit
14ab6004
authored
Aug 22, 2014
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure workers don't pick themselves as victim
parent
9edcd6e1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
libcaf_core/caf/policy/work_stealing.hpp
libcaf_core/caf/policy/work_stealing.hpp
+10
-4
No files found.
libcaf_core/caf/policy/work_stealing.hpp
View file @
14ab6004
...
@@ -94,7 +94,12 @@ class work_stealing {
...
@@ -94,7 +94,12 @@ class work_stealing {
template
<
class
Worker
>
template
<
class
Worker
>
resumable
*
try_steal
(
Worker
*
self
)
{
resumable
*
try_steal
(
Worker
*
self
)
{
auto
p
=
self
->
parent
();
auto
p
=
self
->
parent
();
auto
victim
=
d
(
self
).
rengine
()
%
p
->
num_workers
();
size_t
victim
;
do
{
// roll the dice to pick a victim other than ourselves
victim
=
d
(
self
).
rengine
()
%
p
->
num_workers
();
}
while
(
victim
==
self
->
id
());
return
d
(
p
->
worker_by_id
(
victim
)).
exposed_queue
.
try_pop
();
return
d
(
p
->
worker_by_id
(
victim
)).
exposed_queue
.
try_pop
();
}
}
...
@@ -122,10 +127,11 @@ class work_stealing {
...
@@ -122,10 +127,11 @@ class work_stealing {
// this means we are going to put this job to the very end of our queue
// this means we are going to put this job to the very end of our queue
// by moving everything from the exposed to private queue first and
// by moving everything from the exposed to private queue first and
// then enqueue job to the exposed queue
// then enqueue job to the exposed queue
resumable
*
ptr
=
d
(
self
).
exposed_queue
.
try_pop
();
auto
next
=
[
&
]
{
while
(
ptr
)
{
return
d
(
self
).
exposed_queue
.
try_pop
();
};
for
(
auto
ptr
=
next
();
ptr
!=
nullptr
;
ptr
=
next
())
{
d
(
self
).
private_queue
.
push_front
(
ptr
);
d
(
self
).
private_queue
.
push_front
(
ptr
);
ptr
=
d
(
self
).
exposed_queue
.
try_pop
();
}
}
d
(
self
).
exposed_queue
.
push_back
(
job
);
d
(
self
).
exposed_queue
.
push_back
(
job
);
}
}
...
...
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