Skip to content

Commit 8591bff

Browse files
committed
Added test for proper handling of put!/get priorities
* Added a test that checks if put!/get requests are handled in order of descending priority, as requested by @Krastanov in the discussion of PR #101. This test will currently fail!
1 parent 34ed8dd commit 8591bff

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

test/test_resource_priorities.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,21 @@ put!(sto, :b; priority = 6.0)
5656
put!(sto, :b; priority = BigInt(5))
5757
put!(sto, :b; priority = typemin(UInt))
5858
@show sto.items
59-
@show keys(sto.put_queue)
59+
@show keys(sto.put_queue)
60+
61+
@testset "Resource priority evaluation" begin
62+
using ResumableFunctions
63+
64+
let sim = Simulation()
65+
@resumable function f(env, res)
66+
@yield lock(res)
67+
end
68+
69+
res = Resource(sim)
70+
ev1 = unlock(res, priority=5)
71+
ev2 = unlock(res)
72+
@process f(sim, res)
73+
run(sim)
74+
@test state(ev1) === ConcurrentSim.processed
75+
end
76+
end

0 commit comments

Comments
 (0)