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
50838599
Commit
50838599
authored
May 20, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checkIfResourceCanPreempt() removed as not used any more
parent
7ea60245
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
29 deletions
+2
-29
dream/simulation/ObjectResource.py
dream/simulation/ObjectResource.py
+0
-7
dream/simulation/OperatorPool.py
dream/simulation/OperatorPool.py
+2
-22
No files found.
dream/simulation/ObjectResource.py
View file @
50838599
...
...
@@ -52,13 +52,6 @@ class ObjectResource(object):
def
checkIfResourceIsAvailable
(
self
,
callerObject
=
None
):
return
len
(
self
.
Res
.
activeQ
)
<
self
.
capacity
# =======================================================================
# Check if Operator Can perform a preemption
# =======================================================================
def
checkIfResourceCanPreempt
(
self
,
callerObject
=
None
):
# TODO: each resource will return according to its availability for preemption
return
False
# =======================================================================
# actions to be taken after the simulation ends
# =======================================================================
...
...
dream/simulation/OperatorPool.py
View file @
50838599
...
...
@@ -96,23 +96,7 @@ class OperatorPool(ObjectResource):
# checks if there are operators available
# =======================================================================
def
checkIfResourceIsAvailable
(
self
):
# TODO: to discuss with George if using a callerObject is the proper way to inform the OperatorPreemptive
# about the object that is requesting to know about its availability
# TODO: first check if there is any free operator, then check if the requesting entity is critical and preempt
# if callerOjbect is None then the checkIfResourceIsAvailable performs the default behaviour
# so initially it checks whether there is a free operator
isAvailable
=
any
(
operator
.
checkIfResourceIsAvailable
()
==
True
for
operator
in
self
.
operators
)
if
isAvailable
:
return
True
return
self
.
checkIfResourceCanPreempt
()
# # 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)
# =======================================================================
# checks if there are operators that can preempt
# =======================================================================
def
checkIfResourceCanPreempt
(
self
):
return
any
(
x
for
x
in
self
.
operators
if
x
.
checkIfResourceCanPreempt
(
callerObject
=
self
))
return
any
(
operator
.
checkIfResourceIsAvailable
()
==
True
for
operator
in
self
.
operators
)
# =======================================================================
# find the first available operator and return it
...
...
@@ -120,11 +104,7 @@ class OperatorPool(ObjectResource):
def
findAvailableOperator
(
self
):
# may need to implement different sorting of the operators
# find the free operator if any
freeOperator
=
next
(
x
for
x
in
self
.
operators
if
x
.
checkIfResourceIsAvailable
())
# if freeOperator:
# return freeOperator
return
freeOperator
# # 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
...
...
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