Ticket #77 (new defect)

Opened 8 months ago

Last modified 8 months ago

EM::Timer should have helpers for common operations (reset timer and postpone timer)

Reported by: tmm1 Assigned to: raggi
Priority: minor Milestone: EventMachine "Framework"
Keywords: Cc:

Description

class EventMachine::Timer
  def reset seconds
    prev = EM.instance_variable_get('@timers')[@signature]
    cancel
    initialize(seconds){ prev.call }
  end

  def postpone seconds
    prev = EM.instance_variable_get('@timers')[@signature]
    EM.instance_variable_get('@timers')[@signature] = proc{
      EM.add_timer(seconds){ prev.call }
    }
  end
end

Attachments

timers.patch (1.6 kB) - added by tmm1 on 09/12/08 02:12:06.

Change History

09/05/08 18:03:21 changed by tmm1

initialize should probably also set @seconds, and reset should default to re-using the value of @seconds

09/12/08 02:12:06 changed by tmm1

  • attachment timers.patch added.

09/25/08 17:54:23 changed by tmm1

This patch potentially causes leaks, if it holds a reference to the proc even after its fired. More generally, the behavior of #reset and #postpone is unclear if they are invoked after the timer was already fired.