Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
73263eb9
Commit
73263eb9
authored
Jun 03, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more generic implementation of SelectiveQueue
parent
9a746399
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
dream/simulation/Examples/SelectiveQueue.py
dream/simulation/Examples/SelectiveQueue.py
+4
-3
No files found.
dream/simulation/Examples/SelectiveQueue.py
View file @
73263eb9
...
@@ -4,9 +4,10 @@ from dream.simulation.imports import Queue
...
@@ -4,9 +4,10 @@ from dream.simulation.imports import Queue
class
SelectiveQueue
(
Queue
):
class
SelectiveQueue
(
Queue
):
#override so that it chooses receiver according to priority
#override so that it chooses receiver according to priority
def
selectReceiver
(
self
,
possibleReceivers
=
[]):
def
selectReceiver
(
self
,
possibleReceivers
=
[]):
#if the priorities are the same work as cycle
#if all the possibleReceivers have the same priority work as cycle
if
possibleReceivers
[
0
].
priority
==
possibleReceivers
[
1
].
priority
:
if
len
(
possibleReceivers
):
return
Queue
.
selectReceiver
(
possibleReceivers
)
if
possibleReceivers
.
count
(
possibleReceivers
[
0
])
==
len
(
possibleReceivers
):
return
Queue
.
selectReceiver
(
possibleReceivers
)
# sort the receivers according to their priority
# sort the receivers according to their priority
possibleReceivers
.
sort
(
key
=
lambda
x
:
x
.
priority
,
reverse
=
True
)
possibleReceivers
.
sort
(
key
=
lambda
x
:
x
.
priority
,
reverse
=
True
)
if
possibleReceivers
[
0
].
canAccept
():
if
possibleReceivers
[
0
].
canAccept
():
...
...
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