File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,11 @@ const G = Exponential(MU)
36
36
@yield Timeout(env, rand(F))
37
37
get_spare = Get(spares)
38
38
@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
40
44
@yield Request(repair_facility)
41
45
@yield Timeout(env, rand(G))
42
46
@yield Release(repair_facility)
Original file line number Diff line number Diff line change @@ -21,6 +21,20 @@ struct Timeout <: AbstractEvent
21
21
end
22
22
end
23
23
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
+
24
38
function run (env:: Environment , until:: Number = typemax (Float64))
25
39
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
7
7
cor = new ()
8
8
cor. bev = BaseEvent (env)
9
9
cor. fsmi = func (env, args... )
10
- cor. target = Timeout (env)
10
+ cor. target = Initialize (env)
11
11
cor. resume = @callback execute (cor. target, cor)
12
12
cor
13
13
end
38
38
function interrupt (proc:: Process , cause:: Any = nothing )
39
39
if ! done (proc. fsmi)
40
40
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))
42
42
proc. resume = @callback execute (proc. target, proc)
43
43
end
44
44
end
You can’t perform that action at this time.
0 commit comments