When events for Container
abeham opened this issue · 2 comments
The GasStation example in both SimPy and desmod could be improved by implementing a "WhenAtMost" event for a SimPy Container
. The process _monitor_reservoir
currently polls every 10s which is inefficient as it generates and processes many events that are actually unnecessary.
I implemented WhenAtMost (level falls below x), WhenAtLeast (level rises above x) and WhenChange (some get or put event occurred) for Containers in SimSharp and updated the sample accordingly.
Thanks for this suggestion--it's a good one. Also thanks for SimSharp it is an impressive body of code!
Desmod's Queue
and Pool
have been modified to have when_at_least
and when_at_most
events. The existing when_full
, when_not_full
, and when_any
events are derived from when_at_least
and when_at_most
--this is a nice improvement to have fewer waiter lists.
The gas station example is also updated to use Pool.when_at_most
instead of the timeout-based polling loop.
The one suggestion I did not implement was adding the when_change
event. I do not [yet] see a use case for that event.
Thanks again @abeham for these suggestions!