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
bbd3506f
Commit
bbd3506f
authored
Aug 14, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use of any_of when we wait for many events. It is faster
parent
f5358bb1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
dream/simulation/Machine.py
dream/simulation/Machine.py
+6
-4
No files found.
dream/simulation/Machine.py
View file @
bbd3506f
...
@@ -189,7 +189,7 @@ class Machine(CoreObject):
...
@@ -189,7 +189,7 @@ class Machine(CoreObject):
self
.
preemptQueue
=
self
.
env
.
event
()
self
.
preemptQueue
=
self
.
env
.
event
()
# signal used for informing objectInterruption objects that the current entity processed has finished processnig
# signal used for informing objectInterruption objects that the current entity processed has finished processnig
self
.
endedLastProcessing
=
self
.
env
.
event
()
self
.
endedLastProcessing
=
self
.
env
.
event
()
#===========================================================================
#===========================================================================
# create an operatorPool if needed
# create an operatorPool if needed
#===========================================================================
#===========================================================================
...
@@ -301,7 +301,8 @@ class Machine(CoreObject):
...
@@ -301,7 +301,8 @@ class Machine(CoreObject):
# waitEvent isRequested /interruptionEnd/loadOperatorAvailable
# waitEvent isRequested /interruptionEnd/loadOperatorAvailable
while
1
:
while
1
:
self
.
printTrace
(
self
.
id
,
waitEvent
=
''
)
self
.
printTrace
(
self
.
id
,
waitEvent
=
''
)
receivedEvent
=
yield
self
.
isRequested
|
self
.
interruptionEnd
|
self
.
loadOperatorAvailable
|
self
.
initialWIP
receivedEvent
=
yield
self
.
env
.
any_of
([
self
.
isRequested
,
self
.
interruptionEnd
,
self
.
loadOperatorAvailable
,
self
.
initialWIP
])
self
.
printTrace
(
self
.
id
,
received
=
''
)
self
.
printTrace
(
self
.
id
,
received
=
''
)
# if the machine can accept an entity and one predecessor requests it continue with receiving the entity
# if the machine can accept an entity and one predecessor requests it continue with receiving the entity
if
self
.
isRequested
in
receivedEvent
:
if
self
.
isRequested
in
receivedEvent
:
...
@@ -468,7 +469,8 @@ class Machine(CoreObject):
...
@@ -468,7 +469,8 @@ class Machine(CoreObject):
# else (if interrupted()) set interruption flag to true (only if tinM==0),
# else (if interrupted()) set interruption flag to true (only if tinM==0),
# and recalculate the processing time left tinM, passivate while waiting for repair.
# and recalculate the processing time left tinM, passivate while waiting for repair.
# if a preemption has occurred then react accordingly (proceed with getting the critical entity)
# if a preemption has occurred then react accordingly (proceed with getting the critical entity)
receivedEvent
=
yield
self
.
env
.
timeout
(
self
.
tinM
)
|
self
.
interruptionStart
|
self
.
preemptQueue
# getting processed for remaining processing time tinM
# receivedEvent = yield self.env.timeout(self.tinM) | self.interruptionStart | self.preemptQueue
receivedEvent
=
yield
self
.
env
.
any_of
([
self
.
interruptionStart
,
self
.
env
.
timeout
(
self
.
tinM
)
,
self
.
preemptQueue
])
if
self
.
interruptionStart
in
receivedEvent
:
# if a failure occurs while processing the machine is interrupted.
if
self
.
interruptionStart
in
receivedEvent
:
# if a failure occurs while processing the machine is interrupted.
assert
self
.
interruptionStart
.
value
==
self
.
env
.
now
,
'the interruption has not been processed on the time of activation'
assert
self
.
interruptionStart
.
value
==
self
.
env
.
now
,
'the interruption has not been processed on the time of activation'
self
.
interruptionStart
=
self
.
env
.
event
()
self
.
interruptionStart
=
self
.
env
.
event
()
...
@@ -538,7 +540,7 @@ class Machine(CoreObject):
...
@@ -538,7 +540,7 @@ class Machine(CoreObject):
while
1
:
while
1
:
# wait the event canDispose, this means that the station can deliver the item to successor
# wait the event canDispose, this means that the station can deliver the item to successor
self
.
printTrace
(
self
.
id
,
waitEvent
=
'(canDispose or interruption start)'
)
self
.
printTrace
(
self
.
id
,
waitEvent
=
'(canDispose or interruption start)'
)
receivedEvent
=
yield
self
.
canDispose
|
self
.
interruptionStart
receivedEvent
=
yield
self
.
env
.
any_of
([
self
.
canDispose
,
self
.
interruptionStart
])
# if there was interruption
# if there was interruption
#if self.interrupted():
#if self.interrupted():
# TODO not good implementation
# TODO not good implementation
...
...
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