> Don't use the word "yield" - if i'm not mistaken it is a reserved word for
> potential future use in the JS language.

Ok, I renamed it to wait_until_V8_manages_multi_threads()

;-)

>
> Coincidentally (and inspired by Ryan's post, above), i just (over the past
> few hours) implemented setTimeout() for v8 and to test it i implemented
> sleep() using the approach you just used. Thus, it appears that the answer
> to your question is Yes.

Yeah, it worked, I've just implemented and wrote a test.
A small problem considering long-running scripts with this call is how
to stop them accurately.
I've added a check for a session to be requested to terminate:

Handle<Value> wait_until_V8_manages_multi_threads(const Arguments&
args)
{
  if (session_of_this_script_is_required_to_terminate)
                return ThrowException(String::New("session was terminated"));
 {
   v8::Unlocker unlocker;
   Sleep(args.Length() > 0 ? args[0]->Int32Value() : 0);
 }
 return Undefined();
}


 That said, i haven't tried running several
> contexts, only a few threads within a single context.

My case is several threas, different contexts.

> the set/cancelTimeout() impls are somewhat more involved, but mostly because
> the ability to cancelTimeout() requires so much internal overhead (e.g.
> locking the timer list, which means adding a mutex class to your tree, if
> you don't already have one, which i didn't).

My system implements special call that every script can define that
will be called each second.
So the need for setTimeout() is somehow not so strong:

function each_second()
{
 // this code will be called each second
}


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

Reply via email to