Sha256: 7152a4019b098f1dc2e01902801b044a061a0850629b7d6254576080faad3403
Contents?: true
Size: 686 Bytes
Versions: 1
Compression:
Stored size: 686 Bytes
Contents
require 'singleton' module Rocketman class Pool include Singleton def initialize worker_count = Rocketman.configuration.worker_count latency = Rocketman.configuration.latency @latency = latency @jobs = Queue.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 def schedule(&job) @jobs << job end private def spawn_worker Thread.new do loop do job = @jobs.pop job.call sleep @latency end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rocketman-0.1.1 | lib/rocketman/pool.rb |