_scheduler.add_event(self, d)
end
var _scheduler: Scheduler
+ init do end
end
class NodeSource
# Add the sink `n' the the connected nodes
# Do nothing if `n' is already connected
do
- assert n != null
# Create the collection if needed
if _nexts == null then
_nexts = new ArraySet[NodeSink]
# Remove the sink `n' from the connected nodes
# Do nothing if `n' is not connected
do
- assert n != null
_nexts.remove(n)
end
fun run_for(time_limit: Int)
do
- while true do
+ loop
var node = next_event
if _time > time_limit then
print("Time limit.")
class CountSink
super NodeSink
- readable var _count: Int = 0
+ var count: Int = 0
redef fun recieve(n: NodeSource)
do
- _count = _count + 1
+ count = count + 1
end
end
var _limit: Int
redef fun recieve(n: NodeSource)
do
- var c = _count + 1
+ var c = count + 1
if c >= _limit then
- _count = 0
+ count = 0
send
else
- _count = c
+ count = c
end
end