Class: DRbQS::Task::Registrar
- Inherits:
-
Object
- Object
- DRbQS::Task::Registrar
- Defined in:
- lib/drbqs/task/registrar.rb
Overview
The object of this class is mainly used in DRbQS::Task::Generator#set and calls Fiber.yield.
Instance Method Summary collapse
-
#add(arg) ⇒ Object
Add tasks to server.
-
#create_add(*args, &block) ⇒ Object
Create an object of DRbQS::Task and add it.
-
#initialize(data) ⇒ Registrar
constructor
A new instance of Registrar.
-
#wait ⇒ Object
Wait finishes of all tasks in queue of a server.
Constructor Details
#initialize(data) ⇒ Registrar
Returns a new instance of Registrar.
7 8 9 10 11 |
# 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 |
Instance Method Details
#add(arg) ⇒ Object
Add tasks to server.
15 16 17 18 19 20 21 22 23 24 |
# 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) ⇒ Object
Create an object of DRbQS::Task and add it. The arguments are same as DRbQS::Task.
28 29 30 |
# File 'lib/drbqs/task/registrar.rb', line 28 def create_add(*args, &block) add(DRbQS::Task.new(*args, &block)) end |
#wait ⇒ Object
Wait finishes of all tasks in queue of a server.
33 34 35 |
# File 'lib/drbqs/task/registrar.rb', line 33 def wait Fiber.yield(:wait) end |