模块 DEBUGGER__::MultiProcessGroup
公共实例方法
after_fork(child: true) 点击切换源代码
# File debug-1.10.0/lib/debug/session.rb, line 2073 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) 点击切换源代码
# File debug-1.10.0/lib/debug/session.rb, line 2083 def info msg DEBUGGER__.info "#{msg} (#{@lock_level})" # #{caller.first(1).map{|bt| bt.sub(__dir__, '')}}" end
lock() 点击切换源代码
# File debug-1.10.0/lib/debug/session.rb, line 2125 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?() 点击切换源代码
# File debug-1.10.0/lib/debug/session.rb, line 2087 def locked? # DEBUGGER__.debug{ "locked? #{@lock_level}" } @lock_level > 0 end
multi_process!() 点击切换源代码
# File debug-1.10.0/lib/debug/session.rb, line 2070 def multi_process! end
sync(&b) 点击切换源代码
# File debug-1.10.0/lib/debug/session.rb, line 2150 def sync &b info "sync" lock begin b.call if b ensure unlock end end
unlock() 点击切换源代码
# File debug-1.10.0/lib/debug/session.rb, line 2141 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
私有实例方法
lock_level_down() 点击切换源代码
# File debug-1.10.0/lib/debug/session.rb, line 2097 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() 点击切换源代码
# File debug-1.10.0/lib/debug/session.rb, line 2092 def lock_level_up raise unless @m.owned? @lock_level += 1 end
trylock() 点击切换源代码
# File debug-1.10.0/lib/debug/session.rb, line 2103 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