Class: Workpile::Child

Inherits:
Object
  • Object
show all
Defined in:
lib/workpile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index = ARGV.pop, uri = ARGV.pop) ⇒ Child

Returns a new instance of Child.



86
87
88
89
90
# File 'lib/workpile.rb', line 86

def initialize(index = ARGV.pop, uri = ARGV.pop)
  @index = index
  @service = DRbObject.new_with_uri(uri)
  @service.add_boot_client(Process.pid)
end

Instance Attribute Details

#indexObject

Returns the value of attribute index.



85
86
87
# File 'lib/workpile.rb', line 85

def index
  @index
end

Instance Method Details

#wait_requestObject



92
93
94
95
96
97
98
99
100
# File 'lib/workpile.rb', line 92

def wait_request
  req = @service.pop
  @service.add_working_client(Process.pid)
  at_exit do
    @service.remove_working_client(Process.pid)
    @service.remove_boot_client(Process.pid)
  end
  req
end