class Progenitor::Sequence
Attributes
lock[R]
Public Class Methods
new(start=0)
click to toggle source
# File lib/progenitor/sequence.rb, line 4 def initialize(start=0) @lock = Mutex.new @current = start end
Public Instance Methods
in_sequence(&block)
click to toggle source
# File lib/progenitor/sequence.rb, line 17 def in_sequence(&block) value = next_int block.call value end
next_int()
click to toggle source
# File lib/progenitor/sequence.rb, line 9 def next_int @lock.synchronize do value = @current @current += 1 value end end