File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,7 +36,11 @@ const G = Exponential(MU)
3636 @yield Timeout(env, rand(F))
3737 get_spare = Get(spares)
3838 @yield get_spare | Timeout(env)
39- state(get_spare) != SimJulia.idle ? interrupt(value(get_spare)) : throw(SimJulia.StopSimulation("No more spares!"))
39+ if state(get_spare) != SimJulia.idle
40+ interrupt(value(get_spare))
41+ else
42+ throw(SimJulia.StopSimulation("No more spares!"))
43+ end
4044 @yield Request(repair_facility)
4145 @yield Timeout(env, rand(G))
4246 @yield Release(repair_facility)
Original file line number Diff line number Diff line change @@ -21,6 +21,20 @@ struct Timeout <: AbstractEvent
2121 end
2222end
2323
24+ struct Initialize <: AbstractEvent
25+ bev :: BaseEvent
26+ function Initialize (env:: Environment )
27+ schedule (new (BaseEvent (env)))
28+ end
29+ end
30+
31+ struct Interrupt <: AbstractEvent
32+ bev :: BaseEvent
33+ function Interrupt (env:: Environment )
34+ new (BaseEvent (env))
35+ end
36+ end
37+
2438function run (env:: Environment , until:: Number = typemax (Float64))
2539 run (env, Timeout (env, until- now (env)))
26- end
40+ end
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ mutable struct Process <: DiscreteProcess
77 cor = new ()
88 cor. bev = BaseEvent (env)
99 cor. fsmi = func (env, args... )
10- cor. target = Timeout (env)
10+ cor. target = Initialize (env)
1111 cor. resume = @callback execute (cor. target, cor)
1212 cor
1313 end
3838function interrupt (proc:: Process , cause:: Any = nothing )
3939 if ! done (proc. fsmi)
4040 remove_callback (proc. resume, proc. target)
41- proc. target = Timeout ( environment (proc); priority= typemax (Int8), value= InterruptException (proc, cause))
41+ proc. target = schedule ( Interrupt ( environment (proc) ); priority= typemax (Int8), value= InterruptException (proc, cause))
4242 proc. resume = @callback execute (proc. target, proc)
4343 end
4444end
You can’t perform that action at this time.
0 commit comments