Class: Opee::WorkQueue

Inherits:
Queue show all
Defined in:
lib/opee/workqueue.rb

Overview

Implements a work queue Actor that will distribute jobs to Actors that volunteer to complete those jobs. The primary use is to distribute work or jobs across multiple workers.

Constant Summary

Constant Summary

Constants inherited from Actor

Actor::CLOSING, Actor::RUNNING, Actor::STEP, Actor::STOPPED

Instance Attribute Summary

Attributes inherited from Actor

#name, #state

Instance Method Summary (collapse)

Methods inherited from Queue

#ask, #busy?, #queue_count, #work_queue_size

Methods inherited from Actor

#ask, #ask_timeout, #backed_up, #busy?, #close, #max_queue_count, #method_missing, #on_idle, #priority_ask, #proc_count, #queue_count, #start, #state_string, #step, #stop, #timeout_ask, #wakeup

Constructor Details

- (WorkQueue) initialize(options = {})

Returns a new instance of WorkQueue



8
9
10
11
# File 'lib/opee/workqueue.rb', line 8

def initialize(options={})
  @method = nil
  super(options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Opee::Actor

Instance Method Details

- (Symbol) method

Returns the method invoked on the workers to process a job.

Returns:

  • (Symbol)

    method workers are asked to complete



21
22
23
# File 'lib/opee/workqueue.rb', line 21

def method()
  @workers.size
end

- (Fixnum) worker_count

Returns the number of worker Actors waiting to process jobs.

Returns:

  • (Fixnum)

    number of waiting workers



15
16
17
# File 'lib/opee/workqueue.rb', line 15

def worker_count()
  @workers.size
end