C++ How TO?
Praveen Baratam
praveen.baratam+libev at gmail.com
Thu Dec 16 21:53:42 CET 2010
May be I need to use the NOBLOCK flag with ev_run along with
ev_set_io_collect interval to get the desired functionality.
It can mean unnecessary system calls when there are no watchers to add or
delete. May be the async way as suggested by you is the way ahead.
One important thing with libev is the lack of support for EDGE-Triggered
events like libevent on supported platforms and backends.
Libev can be put to use (as in my use case) not just for IO but for
signalling and in that case EDGE-Triggered events are the efficient way to
perform those operations.
For example ZeroMQ uses edge triggered events to pass signals to various
endpoints. I am actually using Libev to catch and handle those events.
After my discussion with ZeroMQ developer Martin, its impossible to
intercept those events with Libev as it does not support edge-triggered
events.
May be I need to move to libevent to integrate with libzmq!! :-(
Is there any quick hack possible with Libev to enable such functionality?
Thank you!
Praveen
On Thu, Dec 16, 2010 at 3:56 AM, Praveen Baratam <
praveen.baratam+libev at gmail.com <praveen.baratam%2Blibev at gmail.com>> wrote:
>
> My apologies for the garbled and illegible code.
>
> I am attaching the source file to this email.
>
> void runLoop()
> {
> if(_watchCounter)
> {
> ev_run(_loop, EVRUN_ONCE);
> }
>
> if(_watchCounter)
> {
> _io_service.post(boost::bind(&FileService::runLoop, this));
> }
> }
>
> -------> As the callbacks are initiated from with in the "ev_run"function call, i thought that watchers could be added or deleted before the next loop is scheduled from with in those callbacks. So i am checking the counter before scheduling the next loop.
>
> IO_Service class is actually a FIFO task scheduler. All we do is add tasks to the scheduler. Adding watchers, deleting watchers and running the loop are just tasks to the IO_Service.
>
> As far as i could comprehend from Libev docs
>
> *ev_set_io_collect_interval (_loop, _poll_interval);*
>
> sets a time out for the loop, so there is no indefinite wait for the loop to finish. (Please correct me if I am wrong). As soon as the loop times-out or finishes, the next run is scheduled in the queue and before that other tasks such as adding and deleting watchers can execute if they are in the queue.
>
> Thank you for your time reviewing the code.
>
> Praveen
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20101217/a6674314/attachment.html>
More information about the libev
mailing list