On Tue, Sep 24, 2013 at 1:57 PM, Ashish Negi <[email protected]> wrote: > I want to run some javascript from the node c++ addon. > > How can i call / push_task nodejs to execute my javascript so that > everything of nodejs is available to the javascript_that_i_want_to_execute ? > > Are there any existing example ? > > I started learning libuv and found uv_aync_init and uv_async_send. But how > are i integrated then with v8 main loop ? > > I found node_contextify.h/cc but that is not made public for addons ?
There is no V8 main loop. There is however the libuv / node.js event loop. If you want to execute JS code, you can do so with v8::Script::New() or v8::Script::Compile(). If you want to call into an _existing_ JS function, use either v8::Function::Call() or, preferably, node::MakeCallback(). If your add-on uses threads, be advised that it's not safe to call into V8 from another thread, not even when you have the Locker for the main Isolate. You need to set up some kind of communication channel with the main thread. uv_async_send() can help - it wakes up the event loop - but you still need cross-thread synchronization, like a mutex or an rwlock. Libuv provides mutexes, barriers, rwlocks, etc. See uv.h for details. -- -- 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 --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
