On Fri, Sep 18, 2015 at 4:01 PM, Bit Cortex <bitcor...@gmail.com> wrote:
> V8 experts,
>
> I'm having trouble understanding the task scheduling requirements of the
> embedder's v8::Platform implementation. Some questions:
>
> 1. Is it a requirement that all foreground tasks for a given isolate be run
> on the same thread?

I don't think that's a hard requirement, but...

> 2. Must foreground tasks be run with the isolate lock held?

...yes, you have to hold the lock.

> 3. What are the embedder's responsibilities in terms of task cancellation or
> cleanup? How is cleanup supposed to work in general? For example, looking at
> the 4.6 source code, I see that V8 posts both foreground and background
> tasks that hold pointers to the isolate and/or its internals, such as the
> heap. What if the embedder disposes the isolate before a task is executed?

I'm not 100% sure about this one but I think it works like this:

1. Only foreground threads are cancellable.
2. You need to hold the isolate lock when running foreground tasks.
3. The only place where threads are cancelled is in Isolate::Dispose().
4. Ergo, there should be no room for race conditions -
Isolate::Dispose() cleans up after itself.

For background tasks, just flush your background task queue.  I'd
probably opt for flushing both queues before you tear down the
isolate, just to be on the safe side.

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to