Giter Club home page Giter Club logo

Comments (3)

gabrielschulhof avatar gabrielschulhof commented on June 12, 2024

@kevinGodell

Is this referring to anything that uses info.Env() or does that mean something else?

Yes. You must not use any APIs which accept an info.Env() from inside Execute().

What limitations does that put on data that can be passed in and executed?

You must convert any Napi::Value you receive to its native equivalent and store it in the Napi::AsyncWorker subclass instance you create before calling Queue(). That way the secondary thread on which Execute runs accesses only native data.

Will I be able to pass a Napi::Buffer or would I have to convert it to a non-napi value before using it?

You can use the Napi::Buffer class' Data() method to obtain a pointer to the native memory segment the buffer wraps. You can store that pointer inside the Napi::AsyncWorker subclass instance just as you would other native data. You can then freely access it from Execute(). You should perhaps also store a Napi::Reference<Napi::Buffer> in the Napi::AsyncWorker subclass instance to make sure the JavaScript Buffer object is not garbage-collected while the secondary thread is running.

from node-addon-examples.

kevinGodell avatar kevinGodell commented on June 12, 2024

Thanks for the clarification and tip about .Data(). I do appreciate it, @gabrielschulhof.

Follow up question if you don't mind, since I have virtually no c++ skills:

In the example @ line 8, I noticed the part with points(points), estimate(0) and that confused me a bit. What does that do? Is that some shortcut for assigning the values to the private vars instead of doing this->privateVar = passedVar?

from node-addon-examples.

kevinGodell avatar kevinGodell commented on June 12, 2024

Scratch that last question. That is a sub class thing and I understand now. Thanks.

from node-addon-examples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.