File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ are automatically removed from the pool.
20
20
struct ConnectionPool
21
21
outbox:: Channel
22
22
connections:: Set{AbstractConnection}
23
- condition:: Condition
23
+ condition:: Threads. Condition
24
24
end
25
25
26
26
function ConnectionPool (
@@ -30,7 +30,7 @@ function ConnectionPool(
30
30
pool = ConnectionPool (
31
31
outbox,
32
32
connections,
33
- Condition (),
33
+ Threads . Condition (),
34
34
)
35
35
36
36
# Catch errors here, otherwise they are lost to the void.
@@ -68,12 +68,24 @@ current task until that is the case. Also processes incoming connections.
68
68
"""
69
69
function ensure_connection (pool:: ConnectionPool )
70
70
if isempty (pool. connections)
71
- wait (pool. condition)
71
+ lock (pool. condition)
72
+ try
73
+ wait (pool. condition)
74
+ finally
75
+ unlock (pool. condition)
76
+ end
72
77
end
73
78
end
74
79
75
80
Base. wait (pool:: ConnectionPool ) = ensure_connection (pool)
76
- Base. notify (pool:: ConnectionPool ) = notify (pool. condition)
81
+ function Base. notify (pool:: ConnectionPool )
82
+ lock (pool. condition)
83
+ try
84
+ notify (pool. condition)
85
+ finally
86
+ unlock (pool. condition)
87
+ end
88
+ end
77
89
78
90
"""
79
91
process_messages(pool)
You can’t perform that action at this time.
0 commit comments