Class: Ronin::Recon::ValueStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/ronin/recon/value_status.rb

Overview

Represents the status of every value across all queues and workers.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeValueStatus

Returns a new instance of ValueStatus.



30
31
32
# File 'lib/ronin/recon/value_status.rb', line 30

def initialize
  @values = {}
end

Instance Attribute Details

#valuesObject (readonly)

Returns the value of attribute values.



28
29
30
# File 'lib/ronin/recon/value_status.rb', line 28

def values
  @values
end

Instance Method Details

#empty?Boolean

Determines if there are no more values within the queue or being processed by any of the workers.

Returns:

  • (Boolean)


81
82
83
# File 'lib/ronin/recon/value_status.rb', line 81

def empty?
  @values.empty?
end

#job_completed(worker_class, value) ⇒ Object Also known as: job_failed

Records that a worker has completed processing the value.

Parameters:



63
64
65
66
67
68
69
70
71
# File 'lib/ronin/recon/value_status.rb', line 63

def job_completed(worker_class,value)
  if (worker_statuses = @values[value])
    worker_statuses.delete(worker_class)

    if worker_statuses.empty?
      @values.delete(value)
    end
  end
end

#job_started(worker_class, value) ⇒ Object

Records that a worker has dequeued the value and started processing it.

Parameters:



52
53
54
# File 'lib/ronin/recon/value_status.rb', line 52

def job_started(worker_class,value)
  (@values[value] ||= {})[worker_class] = :working
end

#value_enqueued(worker_class, value) ⇒ Object

Records that a value was enqueued for the given worker class.

Parameters:



41
42
43
# File 'lib/ronin/recon/value_status.rb', line 41

def value_enqueued(worker_class,value)
  (@values[value] ||= {})[worker_class] = :enqueued
end