Re: [nodejs] Node Addon: Threads and libuv ref counter (C++)

2012-06-17 Thread Ben Noordhuis
On Mon, Jun 18, 2012 at 2:11 AM, wtfux wrote: > With uv_queue_work Node will automatically stay open until the thread quits. > Do I still need uv_ref or this async_send stuff? Not for thread management but... > What I need but yet have to implement is that the Node's main thread will > stay aliv

Re: [nodejs] Node Addon: Threads and libuv ref counter (C++)

2012-06-17 Thread wtfux
Ben Noordhuis wrote: > > > uv_thread_create() is your best option but, as you mention, it's not > available in v0.6. > I switched over to uv_queue_work() and uv_thread_create() (depending on NODE_VERSION_AT_LEAST as mention in this mail thread). Still not sure about queue_work but I can still

Re: [nodejs] Node Addon: Threads and libuv ref counter (C++)

2012-06-17 Thread Ben Noordhuis
On Sat, Jun 16, 2012 at 3:08 AM, wtfux wrote: > Hey guys, > I'm quite a beginner at C++ but I still try to create a node addon in order > to use a c++ library in node. > I got it working partially but I have a few problems and questions: > > 1. The library I'm using will stay during the whole life

Re: [nodejs] Node Addon: Threads and libuv ref counter (C++)

2012-06-17 Thread Nathan Rajlich
The easiest way to deal with the uv_ref/unref() change is to use the NODE_VERSION_AT_LEAST macro from node_version.h. This is what I did for node-ffi: https://github.com/rbranson/node-ffi/blob/02588f775de89aecde82a43bc537dd09e71d958d/src/callback_info.cc#L135-139 On Sat, Jun 16, 2012 at 10:48 AM,

Re: [nodejs] Node Addon: Threads and libuv ref counter (C++)

2012-06-16 Thread carter-thaxton
It might be worth mentioning that in v0.7 (unstable), and soon in v0.8 (stable), the signatures of uv_ref() and uv_unref() have changed. Old: - uv_ref(uv_loop_t *loop) - uv_unref(uv_loop_t *loop) New: - uv_ref(uv_handle_t *handle) - uv_unref(uv_handle_t *handle) That means you can't really use

Re: [nodejs] Node Addon: Threads and libuv ref counter (C++)

2012-06-15 Thread Dean Mao
There's good slides on doing it here: http://kkaefer.github.com/node-cpp-modules/ I don't think you need a "proper" way of creating threads -- the only thing you can't do is have the thread access the v8 runtime since js is single-threaded. You can use uv_queue_work and just have the thread block

[nodejs] Node Addon: Threads and libuv ref counter (C++)

2012-06-15 Thread wtfux
Hey guys, I'm quite a beginner at C++ but I still try to create a node addon in order to use a c++ library in node. I got it working partially but I have a few problems and questions: 1. The library I'm using will stay during the whole life of the node process and needs to run in an own thread.