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
bbd3e1c0
Commit
bbd3e1c0
authored
Sep 08, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
batch related objects updated to comply with the new singlling norm
parent
028b3187
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
16 deletions
+30
-16
dream/simulation/BatchDecomposition.py
dream/simulation/BatchDecomposition.py
+12
-5
dream/simulation/BatchReassembly.py
dream/simulation/BatchReassembly.py
+18
-11
No files found.
dream/simulation/BatchDecomposition.py
View file @
bbd3e1c0
...
...
@@ -86,23 +86,26 @@ class BatchDecomposition(CoreObject):
receivedEvent
=
yield
self
.
env
.
any_of
([
self
.
isRequested
,
self
.
interruptionStart
,
self
.
initialWIP
])
# if an interruption has occurred
if
self
.
interruptionStart
in
receivedEvent
:
assert
self
.
interruptionStart
.
value
==
self
.
env
.
now
,
'the interruption received by batchDecomposition was created earlier'
transmitter
,
eventTime
=
self
.
interruptionStart
.
value
assert
eventTime
==
self
.
env
.
now
,
'the interruption received by batchDecomposition was created earlier'
self
.
interruptionStart
=
self
.
env
.
event
()
# wait till it is over
yield
self
.
interruptionEnd
assert
self
==
self
.
interruptionEnd
.
value
,
'the victim of the failure is not the object that received the interruptionEnd event'
transmitter
,
eventTime
=
self
.
interruptionEnd
.
value
assert
self
==
transmitter
,
'the victim of the failure is not the object that received the interruptionEnd event'
self
.
interruptionEnd
=
self
.
env
.
event
()
if
self
.
signalGiver
():
break
# if we have initial wip
elif
self
.
initialWIP
in
receivedEvent
:
assert
self
.
initialWIP
.
value
==
self
.
env
,
'initial wip was not sent by the Environment'
transmitter
,
eventTime
=
self
.
initialWIP
.
value
assert
transmitter
==
self
.
env
,
'initial wip was not sent by the Environment'
self
.
initialWIP
=
self
.
env
.
event
()
self
.
isProcessingInitialWIP
=
True
break
# otherwise proceed with getEntity
else
:
requestingObject
=
self
.
isRequested
.
value
else
:
requestingObject
,
eventTime
=
self
.
isRequested
.
value
assert
requestingObject
==
self
.
giver
,
'the giver is not the requestingObject'
self
.
isRequested
=
self
.
env
.
event
()
break
...
...
@@ -138,11 +141,13 @@ class BatchDecomposition(CoreObject):
# if there was no success wait till the receiver is available
while
1
:
yield
self
.
canDispose
transmitter
,
eventTime
=
self
.
canDispose
.
value
self
.
canDispose
=
self
.
env
.
event
()
# signal the receiver again and break
if
self
.
signalReceiver
():
self
.
waitEntityRemoval
=
True
yield
self
.
entityRemoved
transmitter
,
eventTime
=
self
.
entityRemoved
.
value
self
.
waitEntityRemoval
=
False
break
...
...
@@ -151,11 +156,13 @@ class BatchDecomposition(CoreObject):
else
:
while
1
:
yield
self
.
canDispose
transmitter
,
eventTime
=
self
.
canDispose
.
value
self
.
canDispose
=
self
.
env
.
event
()
signaling
=
self
.
signalReceiver
()
if
signaling
:
self
.
waitEntityRemoval
=
True
yield
self
.
entityRemoved
transmitter
,
eventTime
=
self
.
entityRemoved
.
value
self
.
waitEntityRemoval
=
False
break
...
...
dream/simulation/BatchReassembly.py
View file @
bbd3e1c0
...
...
@@ -81,22 +81,25 @@ class BatchReassembly(CoreObject):
while
1
:
receivedEvent
=
yield
self
.
env
.
any_of
([
self
.
isRequested
,
self
.
interruptionStart
,
self
.
initialWIP
])
if
self
.
interruptionStart
in
receivedEvent
:
assert
self
.
interruptionStart
.
value
==
self
.
env
.
now
,
'the interruptionStart received by BatchReassembly later than created'
transmitter
,
eventTime
=
self
.
interruptionStart
.
value
assert
eventTime
==
self
.
env
.
now
,
'the interruptionStart received by BatchReassembly later than created'
self
.
interruptionStart
=
self
.
env
.
event
()
yield
self
.
interruptionEnd
assert
self
==
self
.
interruptionEnd
.
value
,
'the victim of the failure is not the object that received the interruptionEnd event'
transmitter
,
eventTime
=
self
.
interruptionEnd
.
value
assert
self
==
transmitter
,
'the victim of the failure is not the object that received the interruptionEnd event'
self
.
interruptionEnd
=
self
.
env
.
event
()
if
self
.
signalGiver
():
break
# if we have initial wip
elif
self
.
initialWIP
in
receivedEvent
:
assert
self
.
initialWIP
.
value
==
self
.
env
,
'initial wip was not sent by the Environment'
transmitter
,
eventTime
=
self
.
initialWIP
.
value
assert
transmitter
==
self
.
env
,
'initial wip was not sent by the Environment'
self
.
initialWIP
=
self
.
env
.
event
()
self
.
isProcessingInitialWIP
=
True
break
# otherwise proceed with getEntity
else
:
requestingObject
=
self
.
isRequested
.
value
else
:
requestingObject
,
eventTime
=
self
.
isRequested
.
value
assert
requestingObject
==
self
.
giver
,
'the giver is not the requestingObject'
self
.
isRequested
=
self
.
env
.
event
()
self
.
isProcessingInitialWIP
=
False
...
...
@@ -128,14 +131,16 @@ class BatchReassembly(CoreObject):
# if there was interruption
# TODO not good implementation
if
self
.
interruptionStart
in
receivedEvent
:
assert
self
.
interruptionStart
.
value
==
self
.
env
.
now
,
'the interruption has not been processed on the time of activation'
transmitter
,
eventTime
=
self
.
interruptionStart
.
value
assert
eventTime
==
self
.
env
.
now
,
'the interruption has not been processed on the time of activation'
self
.
interruptionStart
=
self
.
env
.
event
()
# wait for the end of the interruption
self
.
interruptionActions
()
# execute interruption actions
# loop until we reach at a state that there is no interruption
while
1
:
yield
self
.
interruptionEnd
# interruptionEnd to be triggered by ObjectInterruption
assert
self
.
env
.
now
==
self
.
interruptionEnd
.
value
,
'the victim of the failure is not the object that received it'
transmitter
,
eventTime
=
self
.
interruptionEnd
.
value
assert
eventTime
==
self
.
env
.
now
,
'the victim of the failure is not the object that received it'
self
.
interruptionEnd
=
self
.
env
.
event
()
if
self
.
Up
and
self
.
onShift
:
break
...
...
@@ -146,10 +151,11 @@ class BatchReassembly(CoreObject):
else
:
continue
if
self
.
canDispose
in
receivedEvent
:
if
self
.
canDispose
.
value
!=
self
.
env
.
now
:
transmitter
,
eventTime
=
self
.
canDispose
.
value
if
eventTime
!=
self
.
env
.
now
:
self
.
canDispose
=
self
.
env
.
event
()
continue
assert
self
.
canDispose
.
valu
e
==
self
.
env
.
now
,
'canDispose signal is late'
assert
eventTim
e
==
self
.
env
.
now
,
'canDispose signal is late'
self
.
canDispose
=
self
.
env
.
event
()
# try to signal a receiver, if successful then proceed to get an other entity
if
self
.
signalReceiver
():
...
...
@@ -165,8 +171,9 @@ class BatchReassembly(CoreObject):
self
.
waitEntityRemoval
=
True
self
.
printTrace
(
self
.
id
,
waitEvent
=
'(entityRemoved)'
)
yield
self
.
entityRemoved
self
.
printTrace
(
self
.
id
,
entityRemoved
=
self
.
entityRemoved
.
value
)
assert
self
.
entityRemoved
.
value
==
self
.
env
.
now
,
'entityRemoved event activated earlier than received'
transmitter
,
eventTime
=
self
.
entityRemoved
.
value
self
.
printTrace
(
self
.
id
,
entityRemoved
=
eventTime
)
assert
eventTime
==
self
.
env
.
now
,
'entityRemoved event activated earlier than received'
self
.
waitEntityRemoval
=
False
self
.
entityRemoved
=
self
.
env
.
event
()
# if while waiting (for a canDispose event) became free as the machines that follows emptied it, then proceed
...
...
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