lib/sideband.rb in sideband-1.0.2 vs lib/sideband.rb in sideband-1.0.3
- old
+ new
@@ -5,33 +5,34 @@
require 'sideband/thread'
require 'sideband/worker'
module Sideband
+ @manager = nil
+
def self.initialize!
- new_manager = Manager.new
+ @manager = Manager.new
if block_given?
begin
- ::Thread.current['sideband.manager'] = new_manager
yield
ensure
join
end
else
- ::Thread.current['sideband.manager'] = new_manager
+ @manager
end
end
def self.join
manager.join
kill
end
def self.kill
manager.kill
- ::Thread.current['sideband.manager'] = nil
+ @manager = nil
end
def self.queue(job = nil)
if job
manager.queue << job
@@ -43,11 +44,11 @@
def self.enqueue(job = nil)
queue(job)
end
def self.manager
- manager = ::Thread.current['sideband.manager']
- manager = initialize! if manager.nil?
- manager
+ m = @manager
+ m = initialize! if m.nil?
+ m
end
end