-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathcontext.jl
43 lines (42 loc) · 1.25 KB
/
context.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using Dash
using Dash.Contexts
@testset "task context" begin
storage = TaskContextStorage()
@test !has_context(storage)
with_context(storage, "test") do
@test has_context(storage)
@test get_context(storage) == "test"
with_context(storage, "inner") do
@test has_context(storage)
@test get_context(storage) == "inner"
end
@test get_context(storage) == "test"
end
@test !has_context(storage)
end
@testset "multiple tasks context" begin
storage = TaskContextStorage()
@test !has_context(storage)
with_context(storage, "test") do
@test has_context(storage)
@test get_context(storage) == "test"
@sync begin
@async begin
@test !has_context(storage)
end
@async begin
with_context(storage, "async_1") do
sleep(0.1)
@test get_context(storage) == "async_1"
end
end
@async begin
with_context(storage, "async_2") do
@test get_context(storage) == "async_2"
end
end
end
@test get_context(storage) == "test"
end
@test !has_context(storage)
end