Skip to content

Commit 3ef172d

Browse files
committed
Removed an Agent test with nigh-impossible timing.
1 parent a20d5ee commit 3ef172d

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

spec/concurrent/agent_spec.rb

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ module Concurrent
99

1010
subject { Agent.new(0, executor: executor) }
1111

12+
after(:each) do
13+
executor.kill
14+
end
15+
1216
let(:observer) do
1317
Class.new do
1418
attr_reader :value
@@ -196,17 +200,12 @@ def trigger_observable(observable)
196200
context '#await' do
197201

198202
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)
207207
subject.await
208-
subject.post { fn = true; sleep 0.1 }
209-
expect(fn).to be_falsey
208+
expect(actual.value).to be true
210209
end
211210

212211
it 'does not alter the value' do

0 commit comments

Comments
 (0)