Sha256: 362d787938342d847a5322e315ddd7c865fbceaf4bf5df1679cd24d0dbf606c0

Contents?: true

Size: 709 Bytes

Versions: 2

Compression:

Stored size: 709 Bytes

Contents

require 'thread'
require 'sideband/version'
require 'sideband/manager'
require 'sideband/queue'
require 'sideband/thread'
require 'sideband/worker'

module Sideband

  @manager = nil

  def self.initialize!
    @manager = Manager.new

    if block_given?
      begin
        yield
      ensure
        join
      end
    else
      @manager
    end
  end

  def self.join
    manager.join
    kill
  end

  def self.kill
    manager.kill
    @manager = nil
  end

  def self.queue(job = nil)
    if job
      manager.queue << job
    else
      manager.queue
    end
  end

  def self.enqueue(job = nil)
    queue(job)
  end

  def self.manager
    m = @manager
    m = initialize! if m.nil?
    m
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sideband-1.0.4 lib/sideband.rb
sideband-1.0.3 lib/sideband.rb