Class: Arachni::Reactor::Tasks

Inherits:
Object
  • Object
show all
Includes:
Mutex_m
Defined in:
lib/arachni/reactor/tasks.rb,
lib/arachni/reactor/tasks/base.rb,
lib/arachni/reactor/tasks/delayed.rb,
lib/arachni/reactor/tasks/one_off.rb,
lib/arachni/reactor/tasks/periodic.rb,
lib/arachni/reactor/tasks/persistent.rb

Overview

Task list.

Author:

Defined Under Namespace

Classes: Base, Delayed, OneOff, Periodic, Persistent

Instance Method Summary collapse

Constructor Details

#initializeTasks

Returns a new instance of Tasks.



26
27
28
29
30
# File 'lib/arachni/reactor/tasks.rb', line 26

def initialize
    super

    @tasks = []
end

Instance Method Details

#<<(task) ⇒ Tasks

Note:

Only unique tasks will be included.

Note:

Will assign self as the task's owner.

Returns self.

Parameters:

  • task (Base)

    Task to add to the list.

Returns:



38
39
40
41
42
43
44
45
# File 'lib/arachni/reactor/tasks.rb', line 38

def <<( task )
    synchronize do
        task.owner = self
        @tasks << task
    end

    self
end

#any?Bool

Returns:

  • (Bool)


77
78
79
# File 'lib/arachni/reactor/tasks.rb', line 77

def any?
    !empty?
end

#call(*args) ⇒ Tasks

Calls all tasks.

Returns:



95
96
97
98
# File 'lib/arachni/reactor/tasks.rb', line 95

def call( *args )
    @tasks.dup.each { |t| t.call *args }
    self
end

#clearTasks

Removes all tasks.

Returns:



84
85
86
87
88
89
90
# File 'lib/arachni/reactor/tasks.rb', line 84

def clear
    synchronize do
        @tasks.clear
    end

    self
end

#delete(task) ⇒ Base?

Returns The task if it was included, nil otherwise.

Parameters:

  • task (Base)

    Task to remove from the list.

Returns:

  • (Base, nil)

    The task if it was included, nil otherwise.



58
59
60
61
62
63
64
# File 'lib/arachni/reactor/tasks.rb', line 58

def delete( task )
    synchronize do
        task = @tasks.delete( task )
        task.owner = nil if task
        task
    end
end

#empty?Bool

Returns:

  • (Bool)


72
73
74
# File 'lib/arachni/reactor/tasks.rb', line 72

def empty?
    @tasks.empty?
end

#hashObject



100
101
102
# File 'lib/arachni/reactor/tasks.rb', line 100

def hash
    @tasks.hash
end

#include?(task) ⇒ Bool

Parameters:

  • task (Base)

    Task to check.

Returns:

  • (Bool)


50
51
52
# File 'lib/arachni/reactor/tasks.rb', line 50

def include?( task )
    @tasks.include? task
end

#sizeInteger

Returns:

  • (Integer)


67
68
69
# File 'lib/arachni/reactor/tasks.rb', line 67

def size
    @tasks.size
end