In Files

  • bundler/worker.rb

Parent

Methods

Class/Module Index [+]

Quicksearch

Bundler::Worker

Constants

POISON

Attributes

name[R]

@return [String] the name of the worker

Public Class Methods

new(size, name, func) click to toggle source

Creates a worker pool of specified size

@param size [Integer] Size of pool @param name [String] name the name of the worker @param func [Proc] job to run in inside the worker pool

 
               # File bundler/worker.rb, line 21
def initialize(size, name, func)
  @name = name
  @request_queue = Queue.new
  @response_queue = Queue.new
  @func = func
  @size = size
  @threads = nil
  SharedHelpers.trap("INT") { abort_threads }
end
            

Public Instance Methods

deq() click to toggle source

Retrieves results of job function being executed in worker pool

 
               # File bundler/worker.rb, line 40
def deq
  result = @response_queue.deq
  raise result.exception if result.is_a?(WrappedException)
  result
end
            
enq(obj) click to toggle source

Enqueue a request to be executed in the worker pool

@param obj [String] mostly it is name of spec that should be downloaded

 
               # File bundler/worker.rb, line 34
def enq(obj)
  create_threads unless @threads
  @request_queue.enq obj
end
            
stop() click to toggle source
 
               # File bundler/worker.rb, line 46
def stop
  stop_threads
end