lib/knj/mutexcl.rb in knjrbfw-0.0.7 vs lib/knj/mutexcl.rb in knjrbfw-0.0.8

- old
+ new

@@ -1,9 +1,9 @@ class Knj::Mutexcl def initialize(args = {}) @args = args - raise "No ':modes' given in arguments." if !@args.has_key?(:modes) + raise "No ':modes' given in arguments." if !@args.key?(:modes) @mutex = Mutex.new @blocked = {} @args[:modes].each do |mode, data| data[:blocks].each do |block| @blocked[block] = { @@ -22,10 +22,10 @@ } ) end def sync(mode) - raise "No such mode: '#{mode}'." if !@args[:modes].has_key?(mode) + raise "No such mode: '#{mode}'." if !@args[:modes].key?(mode) while @blocked[mode][:count].to_i > 0 STDOUT.print "Sleeping because blocked '#{mode}' (#{@blocked[mode][:count]}).\n" sleep 0.1 end \ No newline at end of file