lib/progress.rb in progress-3.1.0 vs lib/progress.rb in progress-3.1.1
- old
+ new
@@ -58,10 +58,11 @@
total = total && total != 0 ? Float(total) : 1.0
@total = total
@current = 0.0
@title = title
+ @mutex = Mutex.new
end
def to_f(inner)
inner = 1.0 if inner > 1.0
inner *= @step if @step
@@ -75,20 +76,20 @@
step = 1 if step.nil?
@step = step
@note = note
ret = yield if block_given?
- Thread.exclusive do
+ @mutex.synchronize do
@current += step
end
ret
end
def set(new_current, note)
@step = new_current - @current
@note = note
ret = yield if block_given?
- Thread.exclusive do
+ @mutex.synchronize do
@current = new_current
end
ret
end
end