Sha256: b4a727bd62ea0a834646c16198611ed831396ff16c03396e8bcf2d51f577c07b
Contents?: true
Size: 815 Bytes
Versions: 1
Compression:
Stored size: 815 Bytes
Contents
require "celluloid/condition" require "tennis/actor" require "tennis/fetcher" require "tennis/worker_pool" module Tennis class Launcher include Actor attr_reader :worker_pool, :fetcher def initialize(options) @stop_condition = Celluloid::Condition.new @worker_pool = WorkerPool.new_link(@stop_condition, options) @fetcher = Fetcher.new_link(worker_pool, options) @worker_pool.fetcher = @fetcher end def start worker_pool.async.start end def stop # Stop fetching fetcher.done! # Gracefully stop the workers that are still working worker_pool.async.stop @stop_condition.wait # Terminate the two actors worker_pool.terminate if worker_pool.alive? fetcher.terminate if fetcher.alive? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tennis-jobs-0.4.0 | lib/tennis/launcher.rb |