On Apr 6, 10:49 pm, Stephan Beal <[email protected]> wrote:
> If, however, i change that to:
>
> v8::Locker locker;
> v8::Locker locker2;
> v8::HandleScope hsc;
to partially answer, but not entirely invalidate my question: i now
see that i would need the second locker (if my hypothesis is correct)
in a different location.
The entire code is:
static void * thread_setTimeout( void * arg )
{
#define THREAD_RETURN return NULL; //::pthread_exit( (void *)0 )
if( ! v8::V8::IsDead() )
{
v8::Locker locker;
v8::HandleScope hsc;
Detail::js_thread_info * jio =
reinterpret_cast<Detail::js_thread_info*>( arg );
/** reminder: copy jio to the stack so we can free it up
immediately
and not worry about a leak via an exception
propagating below... */
const Detail::js_thread_info ji(*jio);
const uint32_t udelay = ji.delay * 1000;
delete jio;
bool isFunc = ji.jv->IsFunction();
typedef v8::Local<v8::Function> LoF;
LoF fh( ( isFunc ) ?
LoF( v8::Function::Cast( *(ji.jv) ) ) : LoF() );
typedef v8::Local<v8::Value> LoS;
LoS jscode( (isFunc) ? LoS() : *(ji.jv) );
do
{
int src = 0;
{
v8::Unlocker ul;
/**
FIXME: for long waits, wake up periodically and see
if
we should still be waiting, otherwise this might
keep
the app from exiting from an arbitrarily long time
after the main thread has gone. But how to know
that?
*/
/**
FIXME: posix has obsoleted usleep() and
recommends
nanonosleep(), with it's much more complicated
interface. OTOH, according to APUE, nanosleep()
is only
required to be defined on platforms which
implement "the
real-time extensions". What to do?
*/
src = ::usleep( udelay );
// Check for cancellation resp. unregister the
timer ID:
Detail::TimerLock lock;
if( ! (ji.isInterval ? lock.has(ji.id) :
lock.take(ji.id)) ) break;
}
if( v8::V8::IsDead() ) break;
if( isFunc )
{
----------> NEW v8::Locker lock2;
fh->Call( ji.jself, 0, 0 );
}
else
{
----------> NEW v8::Locker lock2;
ji.evalfunc->Call( ji.jself, 1, &jscode );
}
} while( ji.isInterval );
}
THREAD_RETURN;
#undef THREAD_RETURN
}
Would that solve the problem i'm having?
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
To unsubscribe, reply using "remove me" as the subject.