[erlang-questions] timer, bug !?

Torben Hoffmann torben.lehoff@REDACTED
Mon Aug 6 22:58:38 CEST 2012


Hi Dmitry,

I cannot say for sure, but 0ms timers does not seem to be a super idea 
regardless of what you are trying to do.

Anyway, you have to remember that the timer module starts a server that 
becomes a bottleneck for all timers.
The timers from the erlang module does not have this problem.

You may want to have a look at the timer module I have created [1], if 
not for anything else, then to read about the pros and cons of the 
different timer options in Erlang.

Cheers,
___
  /orben

[1] https://github.com/lehoff/chronos

On 2012-08-05 06:33, Dmitry Kolesnikov wrote:
> Hello,
>
> I am getting a wired eunit test failure. I am sorry,  the code is complicated and it cannot be share here. In nutshell, I do have a gen_server that uses timer:send_after(...) to send timeout message to itself, often it uses timeout equals to 0. If some other message arrives before timeout, then timer is cancelled by timer:cancel(...)
>
> Sometimes, with probability 1/5 - 1/6 timeout message is duplicated, see log below. However, if I switch to erlang:send_after and erlang:cancel_timer the issue disappears. Doe anyone seen a similar effect? Why timer duplicates message?
>
>
> 07:21:51.683 [error] make timer: <0.183.0> T=0
> 07:21:51.684 [error] timeout <0.183.0>
> ...
> 07:21:51.693 [error] make timer: <0.183.0> T=0
> ...
> 07:21:51.695 [error] cancel timer: <0.183.0>
> 07:21:51.696 [error] make timer: <0.183.0> T = 0
> 07:21:51.696 [error] timeout <0.183.0>
> 07:21:51.697 [error] make timer: <0.183.0> T = 0
> 07:21:51.698 [error] cancel timer: <0.183.0>
> 07:21:51.699 [error] make timer: <0.183.0> T = 0
> 07:21:51.699 [error] timeout <0.183.0>
> 07:21:51.700 [error] make timer: <0.183.0> T = 0
> 07:21:51.701 [error] timeout <0.183.0>
> 07:21:51.701 [error] timeout <0.183.0>
>
> Best Regards, Dmitry
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

-- 
http://www.linkedin.com/in/torbenhoffmann




More information about the erlang-questions mailing list