Skip to content

Commit 9c2094d

Browse files
committed
Modify interrupt handling
1 parent 80302fa commit 9c2094d

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

docs/src/examples/ross.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const G = Exponential(MU)
3737
get_spare = Get(spares)
3838
@yield get_spare | Timeout(env)
3939
if state(get_spare) != SimJulia.idle
40-
interrupt(value(get_spare))
40+
@yield interrupt(value(get_spare))
4141
else
4242
throw(SimJulia.StopSimulation("No more spares!"))
4343
end
@@ -55,7 +55,7 @@ end
5555
end
5656
@yield Timeout(env)
5757
for proc in procs
58-
interrupt(proc)
58+
@yield interrupt(proc)
5959
end
6060
for i in 1:S
6161
@yield Put(spares, @process machine(env, repair_facility, spares))

docs/src/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ julia> using SimJulia
184184
185185
julia> @resumable function driver(env::Environment, car_process::Process)
186186
@yield Timeout(env, 3)
187-
interrupt(car_process)
187+
@yield interrupt(car_process)
188188
end
189189
driver (generic function with 1 method)
190190
```
@@ -233,7 +233,7 @@ DocTestSetup = quote
233233
234234
@resumable function driver(env::Environment, car_process::Process)
235235
@yield Timeout(env, 3)
236-
interrupt(car_process)
236+
@yield interrupt(car_process)
237237
end
238238
239239
@resumable function charge(env::Environment, duration::Number)

src/old/processes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ end
6161
function interrupt(proc::OldProcess, cause::Any=nothing)
6262
if !istaskdone(proc.task)
6363
remove_callback(proc.resume, proc.target)
64-
proc.target = Timeout(environment(proc); priority=typemax(Int8), value=InterruptException(proc, cause))
64+
proc.target = schedule(Interrupt(environment(proc)); priority=typemax(Int8), value=InterruptException(proc, cause))
6565
proc.resume = @callback execute(proc.target, proc)
6666
end
6767
end

src/processes.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ function execute(ev::AbstractEvent, proc::Process)
3636
end
3737

3838
function interrupt(proc::Process, cause::Any=nothing)
39+
env = environment(proc)
3940
if !done(proc.fsmi)
4041
remove_callback(proc.resume, proc.target)
41-
proc.target = schedule(Interrupt(environment(proc)); priority=typemax(Int8), value=InterruptException(proc, cause))
42+
proc.target = schedule(Interrupt(env); priority=typemax(Int8), value=InterruptException(proc, cause))
4243
proc.resume = @callback execute(proc.target, proc)
4344
end
45+
Timeout(env; priority=typemax(Int8))
4446
end

test/processes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ end
2525

2626
@resumable function test_interrupter(sim::Simulation, proc::Process)
2727
@yield Timeout(sim, 2)
28-
interrupt(proc)
28+
@yield interrupt(proc)
2929
end
3030

3131
@resumable function test_interrupted(sim::Simulation)

0 commit comments

Comments
 (0)