Class: NewRelic::Agent::WorkerLoop::LoopTask

Inherits:
Object
  • Object
show all
Defined in:
lib/new_relic/agent/worker_loop.rb

Instance Method Summary collapse

Constructor Details

#initialize(call_period, desc = "", &task_proc) ⇒ LoopTask

Returns a new instance of LoopTask.



99
100
101
102
103
104
# File 'lib/new_relic/agent/worker_loop.rb', line 99

def initialize(call_period, desc="", &task_proc) 
  @call_period = call_period
  @last_invocation_time = Time.now
  @task = task_proc
  @desc = desc
end

Instance Method Details

#executeObject



112
113
114
115
# File 'lib/new_relic/agent/worker_loop.rb', line 112

def execute
  @last_invocation_time = Time.now
  @task.call
end

#next_invocation_timeObject



108
109
110
# File 'lib/new_relic/agent/worker_loop.rb', line 108

def next_invocation_time
  @last_invocation_time + @call_period
end

#to_sObject



105
106
107
# File 'lib/new_relic/agent/worker_loop.rb', line 105

def to_s
  "Task[#{@desc}]"
end