Sha256: 0a018cd6c3014c345cc2b915150a5c9572abc2419058b4357f0cbc32e9f1d1fc
Contents?: true
Size: 804 Bytes
Versions: 6
Compression:
Stored size: 804 Bytes
Contents
module Debugger class Lock def initialize @locker = nil @waiting = [] @locked = false; end def locked? @locked end def lock return if Thread.critical return if @locker == Thread.current while (Thread.critical = true; @locked) @waiting.push Thread.current Thread.stop end @locked = true @locker = Thread.current Thread.critical = false self end def unlock return if Thread.critical return unless @locked unless @locker == Thread.current raise RuntimeError, "unlocked by other" end Thread.critical = true t = @waiting.shift @locked = false @locker = nil Thread.critical = false t.run if t self end end end
Version data entries
6 entries across 6 versions & 1 rubygems