File tree Expand file tree Collapse file tree 2 files changed +0
-52
lines changed Expand file tree Collapse file tree 2 files changed +0
-52
lines changed Original file line number Diff line number Diff line change @@ -146,12 +146,6 @@ def try_acquire_now(permits)
146
146
147
147
def try_acquire_timed ( permits , timeout )
148
148
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
155
149
end
156
150
end
157
151
Original file line number Diff line number Diff line change 101
101
module Concurrent
102
102
describe MutexSemaphore do
103
103
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
150
104
end
151
105
152
106
if Concurrent . on_jruby?
You can’t perform that action at this time.
0 commit comments