module DEBUGGER__::MultiProcessGroup
Public Instance Methods
after_fork(child: true)
click to toggle source
# File debug-1.4.0/lib/debug/session.rb, line 1766 def after_fork child: true if child || !@lock_file @m = Mutex.new @lock_level = 0 @lock_file = open(@lock_tempfile.path, 'w') end end
info(msg)
click to toggle source
# File debug-1.4.0/lib/debug/session.rb, line 1774 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.4.0/lib/debug/session.rb, line 1816 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.4.0/lib/debug/session.rb, line 1778 def locked? # DEBUGGER__.info "locked? #{@lock_level}" @lock_level > 0 end
multi_process!()
click to toggle source
# File debug-1.4.0/lib/debug/session.rb, line 1763 def multi_process! end
sync(&b)
click to toggle source
# File debug-1.4.0/lib/debug/session.rb, line 1841 def sync &b info "sync" lock begin b.call if b ensure unlock end end
unlock()
click to toggle source
# File debug-1.4.0/lib/debug/session.rb, line 1832 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.4.0/lib/debug/session.rb, line 1788 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.4.0/lib/debug/session.rb, line 1783 def lock_level_up raise unless @m.owned? @lock_level += 1 end
trylock()
click to toggle source
# File debug-1.4.0/lib/debug/session.rb, line 1794 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