Busy looping when there are no active watchers
doug at hcsw.org
doug at hcsw.org
Wed Jul 4 23:37:54 CEST 2012
Hi,
I've noticed that if there are no active watchers, waiting on a
condition variable busy loops with AnyEvent (only tried it with
AnyEvent 7.01 and EV backend):
Linux:
$ strace perl -MEV -MAnyEvent -e 'AE::cv->recv'
...
epoll_wait(4, {}, 64, 0) = 0
epoll_wait(4, {}, 64, 0) = 0
epoll_wait(4, {}, 64, 0) = 0
...
Solaris:
$ truss perl -MEV -MAnyEvent -e 'AE::cv->recv'
...
port_getn(4, 0x0814CED0, 64, 1, 0x08047170) = 0 [0]
clock_gettime(4, 0x08047240) = 0
clock_gettime(4, 0x08047240) = 0
port_getn(4, 0x0814CED0, 64, 1, 0x08047170) = 0 [0]
clock_gettime(4, 0x08047240) = 0
clock_gettime(4, 0x08047240) = 0
...
I'm not saying I think this behaviour is wrong since a program
where there are no active watchers is probably broken in some
other way, I'm just wondering why the busy looping happens in
this case. I kind of thought it would "sleep forever".
Sorry if I missed this in the documentation.
Cheers,
Doug
More information about the anyevent
mailing list