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
f050f226
Commit
f050f226
authored
Feb 18, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OperatorPool comments clean-up
parent
3730e733
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
dream/simulation/OperatorPool.py
dream/simulation/OperatorPool.py
+10
-8
No files found.
dream/simulation/OperatorPool.py
View file @
f050f226
...
@@ -101,10 +101,11 @@ class OperatorPool(ObjectResource):
...
@@ -101,10 +101,11 @@ class OperatorPool(ObjectResource):
# if callerOjbect is None then the checkIfResourceIsAvailable performs the default behaviour
# if callerOjbect is None then the checkIfResourceIsAvailable performs the default behaviour
# so initially it checks whether there is a free operator
# so initially it checks whether there is a free operator
isAvailable
=
any
(
operator
.
checkIfResourceIsAvailable
()
==
True
for
operator
in
self
.
operators
)
isAvailable
=
any
(
operator
.
checkIfResourceIsAvailable
()
==
True
for
operator
in
self
.
operators
)
if
isAvailable
:
# if isAvailable:
return
True
# return True
# if there is no free operator, then check if any of the operators can preempt
return
isAvailable
return
any
(
operator
.
checkIfResourceIsAvailable
(
callerObject
=
self
)
==
True
for
operator
in
self
.
operators
)
# # if there is no free operator, then check if any of the operators can preempt
# return any(operator.checkIfResourceIsAvailable(callerObject=self)==True for operator in self.operators)
# =======================================================================
# =======================================================================
# find the first available operator and return it
# find the first available operator and return it
...
@@ -112,10 +113,11 @@ class OperatorPool(ObjectResource):
...
@@ -112,10 +113,11 @@ class OperatorPool(ObjectResource):
def
findAvailableOperator
(
self
):
# may need to implement different sorting of the operators
def
findAvailableOperator
(
self
):
# may need to implement different sorting of the operators
# find the free operator if any
# find the free operator if any
freeOperator
=
next
(
x
for
x
in
self
.
operators
if
x
.
checkIfResourceIsAvailable
())
freeOperator
=
next
(
x
for
x
in
self
.
operators
if
x
.
checkIfResourceIsAvailable
())
if
freeOperator
:
# if freeOperator:
return
freeOperator
# return freeOperator
# if there is no free operator, return the operator that can preempt
return
freeOperator
return
next
(
x
for
x
in
self
.
operators
if
x
.
checkIfResourceIsAvailable
(
callerObject
=
self
))
# # if there is no free operator, return the operator that can preempt
# return next(x for x in self.operators if x.checkIfResourceIsAvailable(callerObject=self))
# =======================================================================
# =======================================================================
# returns the resource
# returns the resource
...
...
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