Thanks for the points about stack space and TLS. (And I understand the
risks that my changes won't be accepted, though I'll try to make them
clean to improve my odds.)

My revised plan is to use v8's thread abstraction to create a  thread
for each of my fibers. That should avoid any issues with TLS.

But there's one point that I'm nervous about: if a thread/fiber runs a
function and then blocks before that function returns, is it safe to
release the v8 lock (with v8::Unlocker, for example) and allow another
thread to execute or could the code on the first thread's stack be
"holding onto object pointers obtained from V8 handles" (quote from
v8.h)? (It's easy to imagine that this would break the rules.)

On Fri, Aug 20, 2010 at 01:06, Erik Corry <[email protected]> wrote:
> 20. aug. 2010 00.38 skrev malcolm handley <[email protected]>:
>> I'm looking into adding to v8 support for fibers or cooperatively
>> scheduled threads. I've read a bunch of posts on v8 and threading so
>> far and my understanding is that it's ok to have multiple threads
>> executing v8 code as long as they hold V8::Locker when they do so
>> (and, hence, that only one of them is executing v8 code at a time).
>>
>> Is this correct? Are there any pitfalls I should be aware of or
>> reasons that this is a non-starter?
>
> I think it could be made to work.
>
> If you plan to have a very large number of fibers you should be aware
> that normal JS programs can use a lot of stack space if the programmer
> makes use of Function.prototype.apply.  This will unfold an array onto
> the stack in the current implementation.
>
> Eddy's comment looks right too.
>
> I can't of course make any guarantees about your chances of getting
> such a change upstreamed.  As always with these things having the
> change be nicely encapsulated, non-intrusive and performance neutral
> for those that don't use it will help.
>
> --
> Erik Corry, Software Engineer
> Google Denmark ApS - Frederiksborggade 20B, 1 sal,
> 1360 København K - Denmark - CVR nr. 28 86 69 84
>
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
>

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to