@request macro does not yield
Closed this issue · 5 comments
Hi Ben,
if I write (as you do e.g. in coroutines_MM1.jl
):
println(@sprintf("%0.2f: Customer %d enqueues", now(sim), n))
push!(queue, n)
@request clerk req begin
pop!(queue)
println(@sprintf("%0.2f: Customer %d being served", now(sim), n))
Δt = rand(DiscreteUniform(1, 5)) + randn()*0.2
@yield return Timeout(sim, Δt)
end
println(@sprintf("%0.2f: Customer %d leaves after %0.2f min", now(sim), n, now(sim)-arrivaltime))
the process does not yield to requested resource clerk
whereas if I write explicitly:
println(@sprintf("%0.2f: Customer %d enqueues", now(sim), n))
push!(queue, n)
@yield return Request(clerk)
shift!(queue)
println(@sprintf("%0.2f: Customer %d being served", now(sim), n))
Δt = rand(DiscreteUniform(1, 5)) + randn()*0.2
@yield return Timeout(sim, Δt)
@yield return Release(clerk)
println(@sprintf("%0.2f: Customer %d leaves after %0.2f min", now(sim), n, now(sim)-arrivaltime))
I get the right behaviour.
I included postoffice1.jl
which does not yield and postoffice2.jl
which works.
postoffice1.jl.txt
postoffice2.jl.txt
Paul
Hi Paul
I just returned from holidays. The @request macro is an ugly hack I have to change. I will try to solve the problem as soon as possible. I will keep you informed. Thanks for your patience.
Ben
Hi Paul
You can find a working example (after master checkout of SimJulia) in gist.
When you use @request you still have to do @yield return req (see an example in tests to balk if the request process has to wait too long).
You don't have to do the queue management yourself (a Resource contains always the needed queues).
I hope this solves your problem.
Kind regards
PS I know I have to finish documentation ... ;)
Hi Ben,
as I wrote in gist you can close the issue, but for reasons described there, I cannot follow you with the queue management.
Kind regards,
Paul
Hi Paul,
I am very interested to make your example more straightforward. To store items you can use a Store
and split logically the queue and the clerk. I will also look at your logging utilities. I keep you informed;)
Kind regards
Ben