File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -185,8 +185,7 @@ def acquire_write_lock
185
185
# Then we are OK to stop waiting and go ahead
186
186
# Otherwise go back and wait again
187
187
c = @counter . value
188
- break if ( c < RUNNING_WRITER ) &&
189
- ( ( c & MAX_READERS ) == 0 ) &&
188
+ break if !running_writer? ( c ) && !running_readers? ( c ) &&
190
189
@counter . compare_and_swap ( c , c +RUNNING_WRITER -WAITING_WRITER )
191
190
end
192
191
break
@@ -244,12 +243,12 @@ def has_waiters?
244
243
private
245
244
246
245
# @!visibility private
247
- def running_readers ( c )
246
+ def running_readers ( c = @counter . value )
248
247
c & MAX_READERS
249
248
end
250
249
251
250
# @!visibility private
252
- def running_readers? ( c )
251
+ def running_readers? ( c = @counter . value )
253
252
( c & MAX_READERS ) > 0
254
253
end
255
254
@@ -259,7 +258,7 @@ def running_writer?(c = @counter.value)
259
258
end
260
259
261
260
# @!visibility private
262
- def waiting_writers ( c )
261
+ def waiting_writers ( c = @counter . value )
263
262
( c & MAX_WRITERS ) / WAITING_WRITER
264
263
end
265
264
@@ -269,12 +268,12 @@ def waiting_writer?(c = @counter.value)
269
268
end
270
269
271
270
# @!visibility private
272
- def max_readers? ( c )
271
+ def max_readers? ( c = @counter . value )
273
272
( c & MAX_READERS ) == MAX_READERS
274
273
end
275
274
276
275
# @!visibility private
277
- def max_writers? ( c )
276
+ def max_writers? ( c = @counter . value )
278
277
( c & MAX_WRITERS ) == MAX_WRITERS
279
278
end
280
279
end
You can’t perform that action at this time.
0 commit comments