Currently, the foreground tasks can run wherever the embedder wants to run
them, but in the future, we might require that it's safe to access the
given isolate from foreground tasks.

Background tasks can run wherever the embedder likes, and they will take
care themselves to use locks etc.. to access the isolate. Some of the tasks
will either do nothing if the isolate was already destroyed by the time
they run, for other tasks, the isolate will block the current thread when
you try to destroy it until all background tasks where executed.

In Chrome on Windows, we also post background tasks to the OS thread pool.

On Mon, Sep 21, 2015 at 5:45 PM Bit Cortex <bitcor...@gmail.com> wrote:

> Ben, thanks for your response. Follow-up questions below:
>
> > 2. Must foreground tasks be run with the isolate lock held?
>>
>> ...yes, you have to hold the lock.
>>
>
> Hmm, I just noticed that v8::platform::DefaultPlatform doesn't acquire the
> lock to run foreground tasks. On the other hand, the V8 samples never run
> scripts and foreground tasks concurrently, so it's unclear whether doing so
> is safe. Also, if holding the lock is a practical requirement, then how
> would you deal with long-running scripts? Would it make sense to implement
> CallOnForegroundThread() via v8::Isolate::RequestInterrupt()?
>
>
>> 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.
>>
>
> Currently I don't have a background task queue; my implementation of
> CallOnBackgroundThread() simply posts a work item to the OS thread pool,
> but looking at what the work items actually do, I don't see how that can be
> safe. In any case, when you say "flush your background task queue", do you
> mean wait until all background tasks are finished executing? That seems
> like it could be a long wait if multiple isolates are concurrently posting
> new background tasks.
>
> Thanks.
>
> --
> --
> 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.
>

-- 
-- 
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