AnyEvent driver for Prima
Dmitry Karasik
dmitry at karasik.eu.org
Fri Dec 16 17:42:15 CET 2016
> > - Prima::Timer's onTick event will guarantee that it won't be
> > triggered after stop() call (so you won't need destroy() to be
> > bulletproof)
>
> Does it also guarantee that if you change the timeout to much higher
> after the first call, using the timeout method, then the timer won't be
> triggered soon? For example,
>
> $watcher = AnyEvent->timer(after => 0, interval => 60, cb =>
> $callback)
>
> will have to guarantee that there's only one early call.
It doesn't, because it is OS-dependant. However on X11 it is my code, and you
can rely that the event won't come early. But on Win32 it's the native SetTimer
call, which according to my evidence doesn't do that ( and googling 'WM_TIMER
fires too early' doesn't bring anything; late - yes, but not early). I think
for all practical purposes you can count on that early timer events won't be
sent.
>
> > - Prima::Component->idle_message method added. Calling this method
> > will insert the component (once) to the global idle list,
> > and when the loop becomes idle, it's onIdle callback will be called,
> > once, and the the component will be removed from the list.
> > However I'm note sure though that I've got the idle semantics right,
> > so if you think that there's something that can be made better,
> > do say.
> AnyEvent's idle watchers are repeating, that is, they don't get removed
> from the idle list until the watcher is destroyed. That's not a big
> difference though, the wrapper can implement either behavior from the
> other.
Thank you, I get it. I changed it again so that it gets called always, but one
can only catch it on $::application. However it doesn't work like a timer of
sorts; if f.ex. the application gets idle, the message is called, once, and
then the program gets to sleep for new events (given absence of running
timers). onIdle won't be fired off until a new event comes, gets handled, and
the application idles again. Hope that makes sense.
--
Sincerely,
Dmitry Karasik
More information about the anyevent
mailing list