Can I use ev_loop only for read ?

xiang qian xqterry at gmail.com
Sun Mar 8 17:22:37 CET 2009


thanks ry

While read & write event of a fd is triggered in same loop of one  
thread, the callbacks are called one by one.
I am forwarding data between 2 fds, just want to read from & write to  
fd concurrently.

On 2009-3-8, at PM9:20, Ryan Dahl wrote:

> Is there a reason to use threads at all? Sounds unnecessary.
>
> If you're doing TCP you might find this code helpful - it has a  
> write queue.
>
> http://github.com/ry/liboi/blob/e4402c2520b58ff8aa31be7423be450d8ecf7397/oi_socket.h#L29
>
>
> ry
>
> On Sun, Mar 8, 2009 at 1:13 PM, xiang qian <xqterry at gmail.com> wrote:
>> Hi
>> I am working for an packet forwarding tool. It opens 2 fds, reads  
>> data from
>> one and sends to another.
>> It was implemented with single thread and uses only default ev_loop  
>> and I
>> will write a multi-threaded version.
>> If I create 2 threads per fd, one for reading and another for  
>> writing,
>> reader threads use libev ev_loop, and put any incoming data into  
>> queue 1st
>> and 2nd,
>> the writer threads just wait for queues and write data to fds but  
>> doesn't
>> use ev_loop to get EV_WRITE event,
>> is there any problem ?
>> Or should I create ev_loop for each writer thread and use  
>> ev_async_send to
>> notify writers when queues get data?
>> Which mode is correct ?
>> thanks
>> _______________________________________________
>> libev mailing list
>> libev at lists.schmorp.de
>> http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
>>
>
> _______________________________________________
> libev mailing list
> libev at lists.schmorp.de
> http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20090309/cf568a8c/attachment.html>


More information about the libev mailing list