Christian, Thank you very much. It was the Persistent<Function> conversion that I needed. Great blog!!! :)
-Jake On Tuesday, February 17, 2015 at 11:54:32 AM UTC-8, Christian Taltas wrote: > > Hi Jake > > It is worth reading strongloop blog: > > http://strongloop.com/strongblog/node-js-v0-12-c-apis-breaking/ > > Regards > > > > On Tuesday, February 17, 2015, Jake Le <[email protected] <javascript:>> > wrote: > >> >> In Node.js v0.10.xx, calling a callback requires a >> Persistent<Function>. Does anyone know to make the below code work in >> Node.js V12? >> >> struct Baton { >> uv_work_t request; >> Persistent<Function> callback;}; >> >> >> somefunction() { >> ... >> >> Baton *baton = new Baton(); >> baton->request.data = baton; >> baton->callback = Persistent<Function>::New(Handle<Function>::Cast(args[0])); >> >> uv_queue_work(uv_default_loop(), &baton->request, Work, AfterWork);.. >> } >> >> void AfterWork(uv_work_t *req) { >> Baton *baton = static_cast<Baton *>(req->data); HandleScope scope; >> >> const int argc = 1; >> Handle<Value> argv[argc] = { String::NewFromUtf8(isolate, "hello world") }; >> >> TryCatch try_catch; >> >> *baton->callback->Call(Context::GetCurrent()->Global(), argc, argv); * >> if (try_catch.HasCaught()) { >> node::FatalException(try_catch); >> } >> >> baton->callback.Dispose(); >> baton->callback.Clear(); >> .. >> } >> >> Thanks, >> -Jake >> >> -- >> Job board: http://jobs.nodejs.org/ >> New group rules: >> https://gist.github.com/othiym23/9886289#file-moderation-policy-md >> Old group rules: >> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >> --- >> You received this message because you are subscribed to the Google Groups >> "nodejs" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/nodejs/03c2fc5d-86c5-4b00-b732-8841de2ea574%40googlegroups.com >> >> <https://groups.google.com/d/msgid/nodejs/03c2fc5d-86c5-4b00-b732-8841de2ea574%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > > -- > Christian Taltas > KPMG Technologies Services - Directeur Général > [email protected] <javascript:> +33 6 24 80 20 11 > www <http://www.arpegeweb.com> +33 1 55 68 60 85 > > > > -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/3ed06539-1f03-4dc9-9c48-4561a16cdd10%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
