Skip to content

Commit 3889344

Browse files
committed
Removed unnecessary ReadWriteLock#to_s method.
1 parent 608bb09 commit 3889344

File tree

3 files changed

+1
-54
lines changed

3 files changed

+1
-54
lines changed

lib/concurrent/atomic/read_write_lock.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -211,21 +211,6 @@ def release_write_lock
211211
true
212212
end
213213

214-
# Returns a string representing *obj*. Includes the current reader and
215-
# writer counts.
216-
def to_s
217-
c = @counter.value
218-
s = if running_writer?(c)
219-
"1 writer running, "
220-
elsif running_readers(c) > 0
221-
"#{running_readers(c)} readers running, "
222-
else
223-
""
224-
end
225-
226-
"#<ReadWriteLock:#{object_id.to_s(16)} #{s}#{waiting_writers(c)} writers waiting>"
227-
end
228-
229214
# Queries if the write lock is held by any thread.
230215
#
231216
# @return [Boolean] true if the write lock is held else false`

spec/concurrent/atomic/read_write_lock_spec.rb

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -489,43 +489,5 @@ module Concurrent
489489
expect(subject.release_write_lock).to be true
490490
end
491491
end
492-
493-
context '#to_s' do
494-
495-
it 'includes the running reader count' do
496-
subject.with_read_lock do
497-
expect(subject.to_s).to match(/1 readers running/)
498-
end
499-
expect(subject.to_s).to_not match(/readers running/)
500-
end
501-
502-
it 'includes the running writer count' do
503-
subject.with_write_lock do
504-
expect(subject.to_s).to match(/1 writer running/)
505-
end
506-
expect(subject.to_s).to_not match(/writer running/)
507-
end
508-
509-
it 'includes the waiting writer count' do
510-
start_latch = Concurrent::CountDownLatch.new(1)
511-
end_latch = Concurrent::CountDownLatch.new(1)
512-
513-
thread = Thread.new do
514-
start_latch.wait(1)
515-
subject.acquire_write_lock
516-
subject.release_write_lock
517-
end_latch.count_down
518-
end
519-
520-
subject.with_write_lock do
521-
start_latch.count_down
522-
sleep(0.1)
523-
expect(subject.to_s).to match(/1 writers waiting/)
524-
end
525-
expect(subject.to_s).to match(/1 writers waiting/)
526-
end_latch.wait(1)
527-
expect(subject.to_s).to match(/0 writers waiting/)
528-
end
529-
end
530492
end
531493
end

yardoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 5aff4706f70d757c15830edd66d74759ff364eda
1+
Subproject commit db7483b80f6efb7df9930f0031508d7e2eb6bad0

0 commit comments

Comments
 (0)