11mutable struct Process <: DiscreteProcess
22 bev :: BaseEvent
3- fsm :: ResumableFunctions.FiniteStateMachineIterator
3+ fsmi :: ResumableFunctions.FiniteStateMachineIterator
44 target :: AbstractEvent
55 resume :: Function
66 function Process (func:: Function , env:: Environment , args:: Any... )
77 cor = new ()
88 cor. bev = BaseEvent (env)
9- cor. fsm = func (env, args... )
9+ cor. fsmi = func (env, args... )
1010 cor. target = Timeout (env)
1111 cor. resume = @callback execute (cor. target, cor)
1212 cor
1515
1616macro process (expr)
1717 expr. head != :call && error (" Expression is not a function call!" )
18- func = esc (expr. args[1 ])
19- args = [esc (expr. args[n]) for n in 2 : length (expr. args)]
20- :(Process ($ (func), $ (args... )))
18+ esc (:(Process ($ (expr. args... ))))
2119end
2220
2321function execute (ev:: AbstractEvent , proc:: Process )
2422 try
2523 env = environment (ev)
2624 set_active_process (env, proc)
27- target = proc. fsm (value (ev))
25+ target = proc. fsmi (value (ev))
2826 reset_active_process (env)
29- if done (proc. fsm )
27+ if done (proc. fsmi )
3028 schedule (proc; value= target)
3129 else
3230 proc. target = state (target) == processed ? Timeout (env; value= value (target)) : target
@@ -38,7 +36,7 @@ function execute(ev::AbstractEvent, proc::Process)
3836end
3937
4038function interrupt (proc:: Process , cause:: Any = nothing )
41- if ! done (proc. fsm )
39+ if ! done (proc. fsmi )
4240 remove_callback (proc. resume, proc. target)
4341 proc. target = Timeout (environment (proc); priority= typemax (Int8), value= InterruptException (proc, cause))
4442 proc. resume = @callback execute (proc. target, proc)
0 commit comments