yes but now i'm changing the work of the class. Now i'm trying to put the uv_run in a thread using UV_RUN_ONCE and sleep a little bit. After uv_run end, the method unlock a mutex so processBufferElement() method can submit a new client maintaining the same same loop.
i'm trying to learn libuv with myself experiment just it is.:-) I'd like to have a central loop where when a connection is performing a write i can begin a new one. Il giorno lunedì 7 luglio 2014 13:59:55 UTC+2, Iñaki Baz Castillo ha scritto: > > 2014-07-07 13:52 GMT+02:00 Claudio Bisegni <[email protected] > <javascript:>>: > > I use libuv because it avoid me to think ad use select/ poll etc.. and > > abstract the tcp async work for a lot of system. > > Sorry, but what you are doing in your processBufferElement() method is: > > - Create a *new* libuv loop. > - Connect via TCP to a server. > - Send data. > - After data is send you close the TCP handle. > - ... so the *blocking call to uv_run() terminates and > processBufferElement() returns. > > So, you are in fact making a blocking code within your > processBufferElement() function. You can run a TCP socket and use > write() in blocking mode, so you do not need to use epoll/select at > all. > > > > > So why i need to write my own async loop when i can use libuv? > > You don't need a loop at all in your code, but just a blocking TCP > write call, that's all. > > > > the problem > > is that i don't know use well the libuv, and i'm searching aroung the > best > > practice to use it. > > > And i don't think that usage of libuv is only for application designed > on it > > directly. > > It is. But first you need to learn how to properly use libuv. > > > > > -- > Iñaki Baz Castillo > <[email protected] <javascript:>> > -- 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 http://groups.google.com/group/libuv. For more options, visit https://groups.google.com/d/optout.
