On Mon, Aug 20, 2012 at 7:23 PM, Navaneeth KN <[email protected]> wrote:
> Hello, > > Thanks for responding. > > On Monday, 20 August 2012 17:37:55 UTC+5:30, Shripad K wrote: >> >> Hello Navaneeth, >> >> One cannot ascertain from the JS code whether the call is going to block >> the event loop or not. In libev, you would register a ev_io watcher and >> listen for EV_READ, EV_WRITE (or both) events (ev_io_init() + >> ev_io_start()) whenever the FD becomes readable/writable. I think the >> equivalent of it is uv_poll_init() + uv_poll_start() in libuv. >> > > I was not talking about will it block the event loop or not. Because I am > not using event loop at all explicitly. All I am doing is directly calling > the C function in my module. I was wondering should I implement using Work > queue (http://nikhilm.github.com/uvbook/threads.html#libuv-work-queue). > > When you say whether it is "blocking call" it can only mean that the event loop is blocked, resulting in the process being blocked. The corresponding C++/C code which the JS function calls might still block the event loop. > The C Library which I am trying to wrap is available here - > https://github.com/navaneeth/libvarnam > Node code is available here - > https://github.com/jijeshmohan/varnam-addon/blob/master/varnam.cc > > >> >> I can see that varnam_init might be a blocking call because it calls sqlite3_open which I assume is blocking call as well? If you can get hold of the underlying FD then you can use uv_poll watcher. If you can't get a reference to the underlying descriptor then you can use a work queue (uv_queue_work) which will execute the blocking call in another thread. Here is an example of the implementation in zeromq.node: https://github.** >> com/JustinTulloss/zeromq.node/**blob/master/binding.cc#L312<https://github.com/JustinTulloss/zeromq.node/blob/master/binding.cc#L312> >> > > Thank you. I will take a look at it. > > Thanks > Navaneeth > >> -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
