English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-01-04 (01:11)
From: SooHyoung Oh <shoh@c...>
Subject: Re: [Caml-list] timer
I have one at http://pllab.kaist.ac.kr/~shoh/ocaml/libs/timer/ .

  Module Timer

module Timer: |sig| .. <http://pllab.kaist.ac.kr/%7Eshoh/ocaml/libs/timer/doc/Timer.html> |end|

timer library. This library uses Sys module and unix, thread library.

type ||id 

callback id. This is returned from registering timer callback and used 
for unregistering.

val init : |?tck_unit:float -> unit -> unit|

initializer timer library. This should be called before calling any 
timer function.

|tck_unit| : tick unit of tick timer. (default value is 100 milli seconds)

val reset : |unit -> unit|

reset timer library. Timer functions can be called anymore.

val register : |(unit -> unit) -> float -> float -> id <http://pllab.kaist.ac.kr/%7Eshoh/ocaml/libs/timer/doc/Timer.html#TYPEid>|

register callback. /register f start interval/ registers callback 
fucntion /f/ which will be called after /start/ milli seconds at first 
and every /interval/ milli seconds after the first calling. If 
/interval/ is zero, the callback function is called only once.
*Returns* id the registered callback id.

val unregister : |id <http://pllab.kaist.ac.kr/%7Eshoh/ocaml/libs/timer/doc/Timer.html#TYPEid> -> unit|

unregister callback.

val msleep : |float -> unit|

sleep for the given time in milli seconds.

Anastasia Gornostaeva ? ?:

>Does exist Timer module, that allows me add/reset/remove timed events?
>Currently I use Unix.setitimer() for my simple implementation that allows
>only adding new events into a queue, but my skills is not enough to implement
>reset and remove events from the Timer queue.
>And I'm not sure if using Unix.sleep() with setitimer() is safely (without
>Caml-list mailing list. Subscription management:
>Archives: http://caml.inria.fr
>Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>Bug reports: http://caml.inria.fr/bin/caml-bugs