You are free to create N loops if somehow, you need them. No use case
coming to my mind, but why not?

Now, when it comes to just handle network sockets, I see no benefit in
having N loops.

Note: mediasoup uses a single libuv loop per worker subprocesses, but it
runs N subprocesses to use all CPUs in the host.

El jue., 25 oct. 2018 13:41, Chen Cong <[email protected]> escribió:

> I am a newbie of libuv :) . I know mediasoup , it just uses one event
> loop(default event loop). So should I just use one event loop in my code,
> and why libuv provides an api to creating uv_loop_t ? The default event
> loop is enough.
>
> 在 2018年10月25日星期四 UTC+8下午7:24:32,Iñaki Baz Castillo写道:
>>
>> One event loop per UDP handle? Well, the idea behind an event loop is
>> not having to create N threads for handling N sockets or file
>> descriptions.
>> On Thu, 25 Oct 2018 at 13:14, Chen Cong <[email protected]> wrote:
>> >
>> > Thanks for your quick reply.
>> >
>> > Actually I implement my own WebRTC ICE stack(I think you know what I
>> mean :) ), and I create one event loop for each udp handle . Because  loop
>> would block the main thread , I also create one thread for each loop (I
>> have no idea if I use the loop in the right way). So uv_udp_try_send is
>> called in the other thread.
>> >
>> > 在 2018年10月25日星期四 UTC+8下午6:07:13,Saúl Ibarra Corretgé写道:
>> >>
>> >>
>> >>
>> >> > On Oct 25, 2018, at 10:10, Chen Cong <[email protected]> wrote:
>> >> >
>> >> > Hi,
>> >> >
>> >> > I use libuv to build a high throughput  udp server , and I have some
>> questions about  libuv.
>> >> >
>> >> > 1.  using "uv_udp_send" or  "uv_udp_try_send" ?  I use
>> "uv_udp_try_send" now , and it seems that "uv_udp_try_send" is thread-safe.
>> >> >
>> >>
>> >> It’s not. Even if it may coincidentally be, that’s en implementation
>> detail. All APIs are thread-UNsafe unsafe unless stated otherwise.
>> >>
>> >> > 2. if "uv_udp_try_send" is better , how can I use it to send packet
>> ? I know "uv_udp_try_send" is not thread-safe,  and I find a related
>> thread. I want to know if  PC-capable pipe server  is still a good way to
>> solve this situation.
>> >> >
>> >>
>> >> I don’t understand the question. One is not better than the other,
>> they server different purposes. uv_udp_try_send will not queue data so you
>> can call it with a stack allocated buffer for example. When using
>> uv_udp_send, the request needs to “survive” until the callback is called.
>> >>
>> >> The typical use case is to try to send the packet with try_send, and
>> if it doesn’t succeed, send it with the regular send.
>> >>
>> >> I don’t understand why you mix threads with these APIs.
>> >>
>> >>
>> >> Cheers,
>> >>
>> >> --
>> >> Saúl
>> >>
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "libuv" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an email to [email protected].
>> > To post to this group, send email to [email protected].
>> > Visit this group at https://groups.google.com/group/libuv.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>> Iñaki Baz Castillo
>> <[email protected]>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "libuv" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/libuv.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.

Reply via email to