Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/async/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ def run(*arguments)
if @status == :initialized
@status = :running

schedule(arguments)
schedule do
@block.call(self, *arguments)
end
else
raise RuntimeError, "Task already running!"
end
Expand Down Expand Up @@ -247,12 +249,12 @@ def stop!
stop_children(true)
end

def schedule(arguments)
def schedule(&block)
@fiber = Fiber.new do
set!

begin
@result = @block.call(self, *arguments)
@result = yield
@status = :complete
# Console.logger.debug(self) {"Task was completed with #{@children.size} children!"}
rescue Stop
Expand Down