Skip to content

Commit 504b114

Browse files
committed
Removed unnecessary semaphore tests.
1 parent 3b5da34 commit 504b114

File tree

2 files changed

+0
-52
lines changed

2 files changed

+0
-52
lines changed

lib/concurrent/atomic/semaphore.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,6 @@ def try_acquire_now(permits)
146146

147147
def try_acquire_timed(permits, timeout)
148148
ns_wait_until(timeout) { try_acquire_now(permits) }
149-
#remaining = Condition::Result.new(timeout)
150-
#while !try_acquire_now(permits) && remaining.can_wait?
151-
#@condition.signal
152-
#remaining = @condition.wait(@mutex, remaining.remaining_time)
153-
#end
154-
#remaining.can_wait? ? true : false
155149
end
156150
end
157151

spec/concurrent/atomic/semaphore_spec.rb

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -101,52 +101,6 @@
101101
module Concurrent
102102
describe MutexSemaphore do
103103
it_should_behave_like :semaphore
104-
105-
context 'spurious wake ups' do
106-
subject { described_class.new(1) }
107-
108-
before(:each) do
109-
def subject.simulate_spurious_wake_up
110-
@mutex.synchronize do
111-
@condition.signal
112-
@condition.broadcast
113-
end
114-
end
115-
116-
subject.drain_permits
117-
end
118-
119-
it 'should resist to spurious wake ups without timeout' do
120-
actual = Concurrent::AtomicBoolean.new(true)
121-
latch = Concurrent::CountDownLatch.new
122-
123-
# would set actual to false
124-
t = Thread.new { latch.wait(1); actual.value = subject.acquire }
125-
126-
latch.count_down
127-
subject.simulate_spurious_wake_up
128-
t.join(0.1)
129-
130-
expect(actual.value).to be true
131-
t.kill
132-
end
133-
134-
it 'should resist to spurious wake ups with timeout' do
135-
actual = Concurrent::AtomicBoolean.new(true)
136-
latch = Concurrent::CountDownLatch.new
137-
138-
# sets actual to false in another thread
139-
t = Thread.new { latch.wait(1); actual.value = subject.try_acquire(1, 0.3) }
140-
141-
latch.count_down
142-
subject.simulate_spurious_wake_up
143-
t.join(0.1)
144-
145-
expect(actual.value).to be true
146-
t.join
147-
expect(actual.value).to be false
148-
end
149-
end
150104
end
151105

152106
if Concurrent.on_jruby?

0 commit comments

Comments
 (0)