How do I cancel a timer?

Marc Lehmann schmorp at
Thu Dec 18 19:53:55 CET 2008

On Thu, Dec 18, 2008 at 07:09:19PM +0200, Graham Leggett <minfrin at> wrote:
> You initialised the area to known values, then you started the timer,  
> then - by mistake - you initialised the already started timer again.

Well, that mistake is simply a bug - once you fix it, everything should

> Are you telling me that it cannot be detected that a timer has a) been  
> initialised and b) started?

Yes - It is also totally obvious, just think about it please: To detect
whether a timer has been started or initialised, you either have to _look_
at the memory it uses (which could happen to have the exact bit pattern
that indicates the timer is active, when it isn't, or worse, the program
could just crash or even worse), or you have to record the address of the
watcher in some extra data structure and check twice (which would be very

Libev wasn't meant as a teaching tool that double-checks the user or
auto-corrects bugs, it's meant as a high-performance library that does
what you tell it with minimal overhead.

If you want double-checking, you could use a language better suited for
learning, such as Perl: the Perl interface to libev (EV) actively checks
for these cases (actually, perl does), as it manages initialisation for
you (actually by not letting you initialise). In general, C is a difficult
language, as it doesn't check your data (or your pointers) for validity,
or tells you when you access iuninitialised memory etc.

                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_    
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      pcg at
      -=====/_/_//_/\_,_/ /_/\_\

More information about the libev mailing list