Method: V::Worker#initialize

Defined in:
lib/v/worker.rb

#initializeWorker

Returns a new instance of Worker.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/v/worker.rb', line 32

def initialize
  @queue = Queue.new

  super do
    while continue?
      operation, environment, thread, future = @queue.pop

      begin
        future.value = operation.call environment

      rescue Exception => e
        thread.raise e

      end if future
    end
  end

  if continue?
    Group.instance.add self
  else
    raise V::ECLOSED
  end
end