Skip to content

Commit

Permalink
Don't need @finished, don't call unblock if cancelled.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Nov 22, 2024
1 parent 785ee50 commit 79cfb7d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/async/work_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ def initialize(scheduler, fiber, work)
@scheduler = scheduler
@fiber = fiber
@work = work
@thread = nil

@finished = false
# The thread, if any, that is doing the work:
@thread = nil

@result = nil
@error = nil
Expand All @@ -29,8 +29,10 @@ def call
rescue => @error
ensure
@thread = nil
@finished = true
@scheduler.unblock(self, @fiber)

if @fiber
@scheduler.unblock(self, @fiber)
end
end

def wait
Expand All @@ -45,6 +47,7 @@ def wait

def cancel!
@work = nil
@fiber = nil # Don't call unblock.
@thread&.raise(Interrupt)
end
end
Expand Down

0 comments on commit 79cfb7d

Please sign in to comment.