lundi 23 février 2015

Storing v8::Persistent in map of structs

I'm trying to implements basic browser javascript setTimeout() using V8, but I have a trouble with storing Persistances. In callback I create v8::Handle function



v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(info[0]);


and cast it to CopyablePersistent



v8::Persistent<v8::Function, v8::CopyablePersistentTraits<v8::Function>> function_(getIsolate(), function);


For handling all callbacks, i create one loop which check every millisecond if we have a callbacks to execute. Callback's strored in std::map



typedef v8::Persistent<v8::Function, v8::CopyablePersistentTraits<v8::Function>> callbackCopyFunc;
enum TimeOutType { INTERVAL, ONCE };
struct TimeOutTask
{
TimeOutType type;
int timeout;
int timePassed;
callbackCopyFunc v8Function;
};
static std::map<uint64_t, TimeOutTask> timeOutTasks


The problem is that i can't access TimeOutTask.v8Function in this loop, i think because of v8::Persistent call Release() in destructor



V8_INLINE ~Persistent() {
if (M::kResetInDestructor) this->Reset();
}

Aucun commentaire:

Enregistrer un commentaire