Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython_plus_experiments
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
Julien Jerphanion
cython_plus_experiments
Commits
4d309ddd
Commit
4d309ddd
authored
Jun 28, 2021
by
Julien Jerphanion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add queues to workers randomly
parent
4c03e3ba
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
kdtree/runtime/runtime.pxd
kdtree/runtime/runtime.pxd
+5
-3
No files found.
kdtree/runtime/runtime.pxd
View file @
4d309ddd
...
...
@@ -106,10 +106,12 @@ cdef cypclass Scheduler:
atomic
[
int
]
num_pending_queues
sem_t
done
volatile
bint
is_done
int
num_workers
lock
Scheduler
__new__
(
alloc
,
int
num_workers
=
0
):
self
=
<
lock
Scheduler
>
consume
alloc
()
if
num_workers
==
0
:
num_workers
=
sysconf
(
_SC_NPROCESSORS_ONLN
)
self
.
num_workers
=
num_workers
sem_init
(
&
self
.
num_free_queues
,
0
,
0
)
sem_init
(
&
self
.
done
,
0
,
0
)
self
.
num_pending_queues
.
store
(
0
)
...
...
@@ -138,10 +140,10 @@ cdef cypclass Scheduler:
void
post_queue
(
self
,
lock
SequentialMailBox
queue
):
# Add a queue to the first worker.
main_worker
=
self
.
workers
[
0
]
with
wlocked
main_work
er
:
receiver
=
self
.
workers
[
rand
()
%
self
.
num_workers
]
with
wlocked
receiv
er
:
queue
.
has_worker
=
True
main_work
er
.
queues
.
push_back
(
queue
)
receiv
er
.
queues
.
push_back
(
queue
)
# Increment the number of non-completed queues.
self
.
num_pending_queues
.
fetch_add
(
1
)
# Signal that a queue is available.
...
...
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