diff --git a/examples/simpleswitch_randomassign/3_simple_run.jl b/examples/simpleswitch_randomassign/3_simple_run.jl index 577230b1..9e0b4b1f 100644 --- a/examples/simpleswitch_randomassign/3_simple_run.jl +++ b/examples/simpleswitch_randomassign/3_simple_run.jl @@ -3,7 +3,7 @@ include("setup.jl") # Prepare all of the simulation components n, sim = prepare_simulation() -step_ts = range(0, 3, step=0.1) +step_ts = range(0, 12, step=0.1) for t in step_ts run(sim, t) end \ No newline at end of file diff --git a/examples/simpleswitch_randomassign/setup.jl b/examples/simpleswitch_randomassign/setup.jl index b2cad3c2..36985704 100644 --- a/examples/simpleswitch_randomassign/setup.jl +++ b/examples/simpleswitch_randomassign/setup.jl @@ -67,7 +67,7 @@ function prepare_simulation() @process consumer() # Finally, set up the switch without assignments - switch_protocol = SimpleSwitchDiscreteProt(net, 1, 2:n+1, fill(1, n), assignment_algorithm=nothing) + switch_protocol = SimpleSwitchDiscreteProt(net, 1, 2:n+1, fill(0.7, n), assignment_algorithm=nothing) @process switch_protocol() return n, sim diff --git a/src/ProtocolZoo/ProtocolZoo.jl b/src/ProtocolZoo/ProtocolZoo.jl index 56df88f3..629080b8 100644 --- a/src/ProtocolZoo/ProtocolZoo.jl +++ b/src/ProtocolZoo/ProtocolZoo.jl @@ -224,23 +224,8 @@ end @yield timeout(prot.sim, prot.retry_lock_time) continue end - if isassigned(a) - traceout!(a) # TODO: why? - end - if isassigned(b) - traceout!(b) # TODO: why? - end - - @info "EntanglerProt: Client $(prot.nodeB) STILL HERE 1" - if islocked(a) - @info "switchnode: $(a) is locked!" - end - if islocked(b) - @info "clientnode: $(b) is locked!" - end + @yield lock(a) & lock(b) # this yield is expected to return immediately - - @info "EntanglerProt: Client $(prot.nodeB) STILL HERE 2" @yield timeout(prot.sim, prot.local_busy_time_pre) attempts = if isone(prot.success_prob) @@ -249,7 +234,7 @@ end rand(Geometric(prot.success_prob))+1 end - if prot.attempts == -1 || prot.attempts >= attempts + if (prot.attempts == -1 || prot.attempts >= attempts) && !isassigned(b) && !isassigned(a) @yield timeout(prot.sim, attempts * prot.attempt_time) initialize!((a,b), prot.pairstate; time=now(prot.sim)) @yield timeout(prot.sim, prot.local_busy_time_post)