class DRbQS::Task::Registrar

The object of this class is mainly used in DRbQS::Task::Generator#set and calls Fiber.yield.

Public Class Methods

new(data) click to toggle source

@param [Hash] data Set instance variables from the hash.

# File lib/drbqs/task/registrar.rb, line 7
def initialize(data)
  data.each do |key, val|
    instance_variable_set("@#{key.to_s}", val)
  end
end

Public Instance Methods

add(arg) click to toggle source

Add tasks to server. @param [DRbQS::Task,Array] arg DRbQS::Task object or array of DRbQS::Task objects, which is added to pool of tasks

# File lib/drbqs/task/registrar.rb, line 15
def add(arg)
  case arg
  when DRbQS::Task
    Fiber.yield(arg)
  when Array
    arg.each { |t| Fiber.yield(t) }
  else
    raise ArgumentError, "An argument must be DRbQS::Task or an array of DRbQS::Task."
  end
end
create_add(*args, &block) click to toggle source

Create an object of DRbQS::Task and add it. The arguments are same as {DRbQS::Task}.

# File lib/drbqs/task/registrar.rb, line 28
def create_add(*args, &block)
  add(DRbQS::Task.new(*args, &block))
end
wait() click to toggle source

Wait finishes of all tasks in queue of a server.

# File lib/drbqs/task/registrar.rb, line 33
def wait
  Fiber.yield(:wait)
end