Sha256: 3a940620471fb021bee3cc57a2479ebbf12a7054ce9a0773ed54616f5e1beaae
Contents?: true
Size: 821 Bytes
Versions: 1
Compression:
Stored size: 821 Bytes
Contents
require 'singleton' require 'rocketman/job_queue' module Rocketman class Pool include Singleton attr_reader :jobs def initialize worker_count = Rocketman.configuration.worker_count latency = Rocketman.configuration.latency @latency = latency @jobs = Rocketman::JobQueue.new @workers = [] worker_count.times do @workers << spawn_worker end # spawn_supervisor # TODO: Write a supervisor to monitor workers health, and restart if necessary end private def spawn_worker Thread.abort_on_exception if Rocketman.configuration.debug Thread.new do loop do job = @jobs.pop job.notify_consumers # Job is an instance of Rocketman::Event sleep @latency end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rocketman-0.3.0 | lib/rocketman/pool.rb |