Skip to content

Commit

Permalink
Lock mismatch fixed as well as success prob <1 (bell pairs only get i…
Browse files Browse the repository at this point in the history
…nitialized when slots not assigned yet)
  • Loading branch information
Luisenden committed Aug 28, 2024
1 parent 7db527e commit 9254884
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
2 changes: 1 addition & 1 deletion examples/simpleswitch_randomassign/3_simple_run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion examples/simpleswitch_randomassign/setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 2 additions & 17 deletions src/ProtocolZoo/ProtocolZoo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 9254884

Please sign in to comment.