V8 doesn't support what you're trying to do. Even if there were a
preemption mechanism, you couldn't use it for this (unlike you really like
crashes).

You'll have to find a way to execute "asynchronous" stuff using only a
single thread. Most likely you'll need some sort of event loop. The module
will have to be loaded, evaluated, and the callback fired either before or
after the potentially long-running code block, but *not* in parallel in the
background.


On Fri, Jun 13, 2014 at 3:05 PM, juu <[email protected]> wrote:

> Hello Sven,
>
> I'm trying to implement Asynchronous Module Definition (
> http://requirejs.org/ ) in my JavaScript IDE based on v8.
>
> require( "../dir/myScript", function(myScriptResult){
>     //Callback function doing something with myScriptResult
> });
>
> //Long running JavaScript code
> //...
>
> require("scriptPath",callback) is here a bound cpp function that will
> create a thread whose job is to load the specified script, evaluate it, and
> return his result as a parameter of the specified callback.
> Asynchronously... My problem is in the "evaluation" part of this script. I
> use only one isolate, which is already locked. So I need a way to unlock it
> and give a chance to my other thread to do some work. The preemption
> allowed me to that, using a context switcher thread.
>
> I know JavaScript is not supposed to be multithreaded, but I don't see any
> other way supporting this feature. Is there other reasons than "Chromium
> and Node don't use preemption" that led to remove it ?
>
>
> On Friday, June 13, 2014 2:26:19 PM UTC+2, Sven Panne wrote:
>
>> On Fri, Jun 13, 2014 at 2:15 PM, juu <[email protected]> wrote:
>>
>>> But if I use multiples isolates, I won't be able to share objects across
>>> Isolates' contexts ? No ?
>>>
>>
>> Nope, hence the term "Isolate"... ;-)
>>
>>
>>> In my case, (AMD Require implementation) the result of my second thread
>>> execution is supposed to be used in my main thread.
>>>
>>
>> I don't fully understand what you're trying to do in detail, but
>> preempting/interrupting the execution of an Isolate, trying to do something
>> else with that Isolate, and later resuming the previous execution
>> definitely won't work (and never did IIRC). You can e.g. interleave the
>> execution of different Isolates in a single thread, or migrate one Isolate
>> to another thread, or have multiple Isolates running at the same time in
>> separate threads, though.
>>
>>   --
> --
> v8-users mailing list
> [email protected]
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
v8-users mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to