Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more
# File singleton.rb, line 176 def _instantiate? @enter.push Thread.current[:i] while false.equal?(@singleton__instance__) @singleton__mutex__.unlock sleep 0.08 @singleton__mutex__.lock end @leave.push Thread.current[:i] @singleton__instance__ end
# File singleton.rb, line 203 def instantiate_all @enter = [] @leave = [] 1.upto(9) {|i| Thread.new { begin Thread.current[:i] = i __sleep instance rescue RuntimeError => mes puts mes end } } puts "Before there were #{num_of_instances(self)}" sleep 3 puts "Now there is #{num_of_instances(self)}" puts "#{@enter.join '; '} was the order of threads entering the waiting loop" puts "#{@leave.join '; '} was the order of threads leaving the waiting loop" end