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
33f02e01
Commit
33f02e01
authored
Jan 16, 2014
by
Ioannis Papagiannopoulos
Committed by
Jérome Perrin
Jan 20, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor changes to ConditionalBuffer haveToDispose()
parent
79a73ba1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
dream/simulation/ConditionalBuffer.py
dream/simulation/ConditionalBuffer.py
+15
-10
No files found.
dream/simulation/ConditionalBuffer.py
View file @
33f02e01
...
...
@@ -51,39 +51,44 @@ class ConditionalBuffer(QueuePreemptive):
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
self
.
getActiveObjectQueue
()
thecaller
=
callerObject
# assert that the callerObject is not None
assert
thecaller
!=
None
,
'the caller object of the ConditionalBuffer should not be None'
# -------------------------------------------------------------------
# check the length of the activeObjectQueue
# if the length is zero then no componentType or entity.type can be read
# in this case return zero
if
len
(
activeObjectQueue
)
==
0
:
return
False
# read the entity to be disposed
activeEntity
=
activeObjectQueue
[
0
]
# assert that the entity.type is OrderComponent
assert
activeEntity
.
type
==
'OrderComponent'
,
\
"the entity to be disposed is not of type OrderComponent"
# -------------------------------------------------------------------
# if the type of the component is Secondary then verify that the basics of the same Order
# are already processed before disposing them to the next object
if
activeEntity
.
componentType
==
'Secondary'
\
and
(
not
activeEntity
.
order
.
basicsEnded
):
return
False
# -------------------------------------------------------------------
#if we have only one possible receiver just check if the receiver is the caller
if
(
len
(
activeObject
.
next
)
==
1
or
callerObject
==
None
):
activeObject
.
receiver
=
activeObject
.
next
[
0
]
return
thecaller
==
activeObject
.
receiver
# -------------------------------------------------------------------
#give the entity to the possible receiver that is waiting for the most time.
#plant does not do this in every occasion!
maxTimeWaiting
=
0
# loop through the object in the successor list
# loop through the object in the successor list
for
object
in
activeObject
.
next
:
if
(
object
.
canAccept
(
activeObject
)):
# if the object can accept
timeWaiting
=
now
()
-
object
.
timeLastEntityLeft
# compare the time that it has been waiting
if
(
timeWaiting
>
maxTimeWaiting
or
maxTimeWaiting
==
0
):
# with the others'
# if the object can accept
if
(
object
.
canAccept
(
activeObject
)):
timeWaiting
=
now
()
-
object
.
timeLastEntityLeft
# compare the time that it has been waiting with the others'
if
(
timeWaiting
>
maxTimeWaiting
or
maxTimeWaiting
==
0
):
maxTimeWaiting
=
timeWaiting
self
.
receiver
=
object
# and update the receiver to the index of this object
# and update the receiver to the index of this object
self
.
receiver
=
object
#return True if the Queue caller is the receiver
return
thecaller
is
self
.
receiver
...
...
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