Sha256: f63e2a45782d71e41eceddc4211e9d8b869cd5859a88e1e4b06f11d2fb19cfa5
Contents?: true
Size: 636 Bytes
Versions: 3
Compression:
Stored size: 636 Bytes
Contents
#-- # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE # Version 2, December 2004 # # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION # # 0. You just DO WHAT THE FUCK YOU WANT TO. #++ require 'thread' class RecursiveMutex < Mutex def initialize @threads = Hash.new { |h, k| h[k] = 0 } super end def lock @thread[Thread.current] += 1 if @thread[Thread.current] == 1 super end end def unlock @thread[Thread.current] -= 1 if @thread[Thread.current] == 0 @thread.delete(Thread.current) super end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
thread-0.0.2 | lib/thread/recursive_mutex.rb |
thread-0.0.1.1 | lib/thread/recursive_mutex.rb |
thread-0.0.1 | lib/thread/recursive_mutex.rb |