Hi,

I was wondering could point me in the in the right direction.
I have a C library running in a thread #1. When works arrive in thread #1, 
work is queued on to a Queue, and the thread wakes up thread #2 through 
uv_async_send, which wakes up the libuv event loop. Thread #2 gets the work 
from the Queue and invokes v8.

A lot of the work enqueued by thread #1 is a small buffer of ~64kb that 
needs to be duplicated before it is enqueued. This memory duplication can 
be slow because of malloc. From my understanding of nodejs, small buffers 
in nodejs are allocated from a managed memory pool, avoiding the need to 
call malloc frequently.

What I would like to do is have thread #1 directly create a node::Buffer / 
Nan;:Buffer, add the work to Queue, and have the uv event loop woken up.

So here's my questions.
1)  How can I create an object in thread #1 that will persist in to the 
second thread?
One option would be to create a Persistent object and then clearing it once 
it's finished.
Second option, which I'm not sure would work, and I wouldn't know why it 
won't work, would be to create the buffer in thread #1 and Escaping it with 
an EscapableHandlescope. 

2) Is it even worth it?
My understanding is that I would have to create a v8::Locker in thread #1 
to ensure thread safety.
Would creating and acquiring the v8::Locker be much slower than just 
malloc'ing a small buffer?

Thanks for the answers and insights in to v8/nodejs.
Eric

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
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 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/5535399e-e83b-46d6-b419-4704071979d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to