[Eventmachine-talk] EventMachine::cancel_timer(signature)

9 views
Skip to first unread message

Paul Johnston

unread,
Aug 9, 2008, 1:47:44 AM8/9/08
to eventmac...@rubyforge.org
I don't understand the rationale for making EventMachine::cancel_timer
a private class method (version 0.12, eventmachine.rb, line 340). If
the signature is exposed as the return value of calling add_timer, why
not let the user make some use of it?

I'm aware I can create a Timer directly
(http://rubyforge.org/pipermail/eventmachine-talk/2007-December/001269.html),
but then I'm responsible for maintaining a reference to the Timer
object rather than the signature. I can workaround it, just
interested in the design choice.

Thoughts appreciated.

Paul Johnston
_______________________________________________
Eventmachine-talk mailing list
Eventmac...@rubyforge.org
http://rubyforge.org/mailman/listinfo/eventmachine-talk

Aman Gupta

unread,
Aug 9, 2008, 6:06:04 PM8/9/08
to eventmac...@rubyforge.org
I'm not sure why cancel_timer is private, but you can always do:

EM.__send__(:cancel_timer, timer_sig)

Probably does make a lot more sense as a public method though. Would
you mind opening a ticket on the Trac (http://rubyeventmachine.com/
newticket)

Aman

On Aug 8, 10:47 pm, "Paul Johnston" <pcj...@gmail.com> wrote:
> I don't understand the rationale for making EventMachine::cancel_timer
> a private class method (version 0.12, eventmachine.rb, line 340).  If
> the signature is exposed as the return value of calling add_timer, why
> not let the user make some use of it?
>
> I'm aware I can create a Timer directly

> (http://rubyforge.org/pipermail/eventmachine-talk/2007-December/001269...),


> but then I'm responsible for maintaining a reference to the Timer
> object rather than the signature.  I can workaround it, just
> interested in the design choice.
>
> Thoughts appreciated.
>
> Paul Johnston
> _______________________________________________
> Eventmachine-talk mailing list

> Eventmachine-t...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/eventmachine-talk

Brian Takita

unread,
Aug 9, 2008, 6:18:16 PM8/9/08
to eventmac...@rubyforge.org
On Sat, Aug 9, 2008 at 3:06 PM, Aman Gupta <themast...@gmail.com> wrote:
> I'm not sure why cancel_timer is private, but you can always do:
>
> EM.__send__(:cancel_timer, timer_sig)
You can also do:
module EventMachine
public :cancel_timer
end

to avoid needing to use #__send__.

Paul Johnston

unread,
Aug 10, 2008, 1:01:23 AM8/10/08
to eventmac...@rubyforge.org
On Sat, Aug 9, 2008 at 3:18 PM, Brian Takita <brian....@gmail.com> wrote:
> On Sat, Aug 9, 2008 at 3:06 PM, Aman Gupta <themast...@gmail.com> wrote:
>> I'm not sure why cancel_timer is private, but you can always do:
>>
>> EM.__send__(:cancel_timer, timer_sig)
> You can also do:
> module EventMachine
> public :cancel_timer
> end
>
> to avoid needing to use #__send__.
>>

Thanks, those are both good solutions.

Reply all
Reply to author
Forward
0 new messages