Hi,
I'm using v8 - v8_13185_v3.15.11 - on Windows, Win7 64bit in multi-threaded environment: several scripts are running parallel.
At an arbitrary time I want to terminate certain running scripts or maybe all from another thread. Some of the scripts may have infinite loops. Everything works fine, until some scripts call dosleep() in a FunctionTemplate defined as follows:
(In thread script[n])
v8::Handle<v8::Value> DoSleep(const v8::Arguments& args) {
int millisec = args[0]->ToInt32()->Int32Value();
if (millisec)
{
v8::Unlocker unlock;
v8::internal::OS::Sleep(millisec);
}
return v8::Undefined();
}
…
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
global->Set(v8::String::New("dosleep"), v8::FunctionTemplate::New(DoSleep));
…
The JavaScript Code looks sg. like this:
v8::Script::Compile(v8::String::New("function f() { while(true) {dosleep(500);} } f()"))->Run();
In the main thread I call:
v8::Locker locker;
for (int i = 0; i < kThreads; i++) {
v8::V8::TerminateExecution(threads[i]->GetV8ThreadId());
The threads calling dosleep() won`t terminate. If I change the DoSleep() Function() to:
v8::Handle<v8::Value> DoSleep(const v8::Arguments& args) {
int millisec = args[0]->ToInt32()->Int32Value();
if (millisec)
{
v8::Unlocker unlock;
for (int i = count; i--;) for (int j = 1000; j--;) ;
}
return v8::Undefined();
}
then the threads calling dosleep() will be terminated.
I have modified test-thread-termination.cc to demonstrate the behavior. After replacing test-thread-termination.cc with the attached one and compiling of ccttest the tests can be called by:
C:\v8_13185_v3.15.11\build\Release>cctest test-thread-termination/TerminateMultipleV8ThreadsWithDelayDefaultIsolate => OK
C:\v8_13185_v3.15.11\build\Release>cctest test-thread-termination/TerminateMultipleV8ThreadsWithSleepDefaultIsolate => Failed: no termination
Is this a bug? If not, how can I terminate scripts calling sleep()?
Thank you,
Laszlo
--
--
v8-users mailing list
v8-u...@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+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--