-
-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #291 from phstc/thread-pool
RIP Celluloid, Hello concurrent-ruby/Thread pool Fixes #185
- Loading branch information
Showing
17 changed files
with
126 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,19 @@ | ||
module Shoryuken | ||
class Launcher | ||
include Celluloid | ||
include Util | ||
|
||
trap_exit :actor_died | ||
|
||
attr_accessor :manager | ||
|
||
def initialize | ||
@condvar = Celluloid::Condition.new | ||
@manager = Shoryuken::Manager.new_link(@condvar) | ||
|
||
@done = false | ||
|
||
manager.fetcher = Shoryuken::Fetcher.new | ||
manager.polling_strategy = Shoryuken.options[:polling_strategy].new(Shoryuken.queues) | ||
@manager = Shoryuken::Manager.new(Shoryuken::Fetcher.new, | ||
Shoryuken.options[:polling_strategy].new(Shoryuken.queues)) | ||
end | ||
|
||
def stop(options = {}) | ||
watchdog('Launcher#stop') do | ||
@done = true | ||
|
||
manager.async.stop(shutdown: !!options[:shutdown], timeout: Shoryuken.options[:timeout]) | ||
@condvar.wait | ||
manager.terminate | ||
end | ||
@manager.stop(shutdown: !options[:shutdown].nil?, | ||
timeout: Shoryuken.options[:timeout]) | ||
end | ||
|
||
def run | ||
watchdog('Launcher#run') do | ||
manager.async.start | ||
end | ||
end | ||
|
||
def actor_died(actor, reason) | ||
return if @done | ||
logger.warn { "Shoryuken died due to the following error, cannot recover, process exiting: #{reason}" } | ||
exit 1 | ||
@manager.start | ||
end | ||
end | ||
end |
Oops, something went wrong.