File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ module Concurrent
9
9
10
10
subject { Agent . new ( 0 , executor : executor ) }
11
11
12
+ after ( :each ) do
13
+ executor . kill
14
+ end
15
+
12
16
let ( :observer ) do
13
17
Class . new do
14
18
attr_reader :value
@@ -196,17 +200,12 @@ def trigger_observable(observable)
196
200
context '#await' do
197
201
198
202
it 'waits until already sent updates are done' do
199
- fn = false
200
- subject . post { fn = true ; sleep 0.1 }
201
- subject . await
202
- expect ( fn ) . to be_truthy
203
- end
204
-
205
- it 'does not waits until updates sent after are done' do
206
- fn = false
203
+ actual = Concurrent ::AtomicBoolean . new ( false )
204
+ latch = Concurrent ::CountDownLatch . new
205
+ subject . post { latch . count_down ; sleep ( 0.1 ) ; actual . make_true }
206
+ latch . wait ( 1 )
207
207
subject . await
208
- subject . post { fn = true ; sleep 0.1 }
209
- expect ( fn ) . to be_falsey
208
+ expect ( actual . value ) . to be true
210
209
end
211
210
212
211
it 'does not alter the value' do
You can’t perform that action at this time.
0 commit comments