module DEBUGGER__::MultiProcessGroup
Public Instance Methods
after_fork(child: true)
click to toggle source
# File debug-1.6.3/lib/debug/session.rb, line 1894 def after_fork child: true if child || !@lock_file @m = Mutex.new unless @m @m.synchronize do @lock_level = 0 @lock_file = open(@lock_tempfile.path, 'w') end end end
info(msg)
click to toggle source
# File debug-1.6.3/lib/debug/session.rb, line 1904 def info msg DEBUGGER__.info "#{msg} (#{@lock_level})" # #{caller.first(1).map{|bt| bt.sub(__dir__, '')}}" end
lock()
click to toggle source
# File debug-1.6.3/lib/debug/session.rb, line 1946 def lock unless trylock @m.synchronize do if locked? lock_level_up else info "Lock: block" @lock_file.flock(File::LOCK_EX) lock_level_up end end info "Lock: success" end end
locked?()
click to toggle source
# File debug-1.6.3/lib/debug/session.rb, line 1908 def locked? # DEBUGGER__.info "locked? #{@lock_level}" @lock_level > 0 end
multi_process!()
click to toggle source
# File debug-1.6.3/lib/debug/session.rb, line 1891 def multi_process! end
sync(&b)
click to toggle source
# File debug-1.6.3/lib/debug/session.rb, line 1971 def sync &b info "sync" lock begin b.call if b ensure unlock end end
unlock()
click to toggle source
# File debug-1.6.3/lib/debug/session.rb, line 1962 def unlock @m.synchronize do raise "lock file is not opened (#{@lock_file.inspect})" if @lock_file.closed? lock_level_down @lock_file.flock(File::LOCK_UN) unless locked? info "Unlocked" end end
Private Instance Methods
lock_level_down()
click to toggle source
# File debug-1.6.3/lib/debug/session.rb, line 1918 def lock_level_down raise unless @m.owned? raise "@lock_level underflow: #{@lock_level}" if @lock_level < 1 @lock_level -= 1 end
lock_level_up()
click to toggle source
# File debug-1.6.3/lib/debug/session.rb, line 1913 def lock_level_up raise unless @m.owned? @lock_level += 1 end
trylock()
click to toggle source
# File debug-1.6.3/lib/debug/session.rb, line 1924 def trylock @m.synchronize do if locked? lock_level_up info "Try lock, already locked" true else case r = @lock_file.flock(File::LOCK_EX | File::LOCK_NB) when 0 lock_level_up info "Try lock with file: success" true when false info "Try lock with file: failed" false else raise "unknown flock result: #{r.inspect}" end end end end