Skip to content

Commit 81a711e

Browse files
committed
Correct bug in previous commit
1 parent c24c07e commit 81a711e

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/base.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
abstract type AbstractEvent end
22
abstract type Environment end
33

4-
@enum EVENT_STATE idle=0 scheduled=1 triggered=2 processed=3
4+
@enum EVENT_STATE idle=0 scheduled=1 processed=2
55

66
struct EventProcessed <: Exception
77
ev :: AbstractEvent
@@ -61,6 +61,7 @@ function remove_callback(cb::Function, ev::AbstractEvent)
6161
end
6262

6363
function schedule(ev::AbstractEvent, delay::Number=zero(Float64); priority::Int8=zero(Int8), value::Any=nothing)
64+
state(ev) == processed && throw(EventProcessed(ev))
6465
env = environment(ev)
6566
bev = ev.bev
6667
bev.value = value

src/operators.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ function check(ev::AbstractEvent, op::Operator, event_state_values::Dict{Abstrac
4040
end
4141

4242
function eval_and(state_values::Vector{StateValue})
43-
all(map((sv)->sv.state >= triggered, state_values))
43+
all(map((sv)->sv.state == processed, state_values))
4444
end
4545

4646
function eval_or(state_values::Vector{StateValue})
47-
any(map((sv)->sv.state >= triggered, state_values))
47+
any(map((sv)->sv.state == processed, state_values))
4848
end
4949

5050
function (&)(ev1::AbstractEvent, ev2::AbstractEvent)

src/simulations.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@ function step(sim::Simulation)
3434
(bev, key) = DataStructures.peek(sim.heap)
3535
DataStructures.dequeue!(sim.heap)
3636
sim.time = key.time
37-
bev.state = triggered
37+
bev.state = processed
3838
for callback in bev.callbacks
3939
callback()
4040
end
41-
bev.state = processed
42-
nothing
4341
end
4442

4543
function now(sim::Simulation)

0 commit comments

Comments
 (0)