lib/async/task.rb in async-1.4.1 vs lib/async/task.rb in async-1.5.0

- old
+ new

@@ -63,11 +63,11 @@ @reactor = reactor @status = :initialized @result = nil - @condition = nil + @finished = nil @fiber = Fiber.new do |*args| set! begin @@ -97,11 +97,11 @@ attr :reactor def_delegators :@reactor, :timeout, :sleep # Yield back to the reactor and allow other fibers to execute. def yield - self.sleep(0) + reactor.yield end # @attr fiber [Fiber] The fiber which is being used for the execution of this task. attr :fiber def_delegators :@fiber, :alive? @@ -132,12 +132,12 @@ # @return [Object] def result raise RuntimeError.new("Cannot wait on own fiber") if Fiber.current.equal?(@fiber) if running? - @condition ||= Condition.new - @condition.wait + @finished ||= Condition.new + @finished.wait else Task.yield {@result} end end @@ -184,11 +184,11 @@ def finish! # Attempt to remove this node from the task tree. consume # If this task was being used as a future, signal completion here: - if @condition - @condition.signal(@result) + if @finished + @finished.signal(@result) end end # Set the current fiber's `:async_task` to this task. def set!