File: hash_spec.rb

package info (click to toggle)
ruby-thread-safe 0.3.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 712 kB
  • sloc: java: 5,458; ruby: 2,917; makefile: 6
file content (17 lines) | stat: -rw-r--r-- 348 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module ThreadSafe
  describe Hash do 
    let!(:hsh) { described_class.new }

    it 'concurrency' do
      (1..THREADS).map do |i|
        Thread.new do
          1000.times do |j|
            hsh[i * 1000 + j] = i
            hsh[i * 1000 + j]
            hsh.delete(i * 1000 + j)
          end
        end
      end.map(&:join)
    end
  end
end