Barretenberg
The ZK-SNARK library at the core of Aztec
|
Encapsulatest some work that can be done off the JavaScript main thread. More...
#include <async_op.hpp>
Public Member Functions | |
AsyncOperation (Napi::Env env, std::shared_ptr< Napi::Promise::Deferred > deferred, async_fn fn) | |
AsyncOperation (const AsyncOperation &)=delete | |
AsyncOperation & | operator= (const AsyncOperation &)=delete |
AsyncOperation (AsyncOperation &&)=delete | |
AsyncOperation & | operator= (AsyncOperation &&)=delete |
~AsyncOperation () override=default | |
void | Execute () override |
void | OnOK () override |
void | OnError (const Napi::Error &e) override |
Private Attributes | |
async_fn | _fn |
std::shared_ptr< Napi::Promise::Deferred > | _deferred |
msgpack::sbuffer | _result |
Encapsulatest some work that can be done off the JavaScript main thread.
This class takes a Deferred instance (i.e. a Promise to JS), execute some work in a separate thread, and then report back on the result. The async execution must not touch the JS environment. Everything that's needed to complete the work must be copied into memory owned by the C++ code. The same has to be done when reporting back the result: keep the result in memory owned by the C++ code and copy it back to the JS environment in the OnOK/OnError methods.
OnOK/OnError will be called on the main JS thread, so it's safe to interact with the JS environment there.
Instances of this class are managed by the NodeJS environment and execute on a libuv thread. Docs . - https://github.com/nodejs/node-addon-api/blob/cc06369aa4dd29e585600b8b47839c1297df962d/doc/async_worker.md . - https://nodejs.github.io/node-addon-examples/special-topics/asyncworker
Definition at line 27 of file async_op.hpp.
|
inline |
Definition at line 29 of file async_op.hpp.
|
delete |
|
delete |
|
overridedefault |
|
inlineoverride |
Definition at line 42 of file async_op.hpp.
|
inlineoverride |
Definition at line 56 of file async_op.hpp.
|
inlineoverride |
Definition at line 51 of file async_op.hpp.
|
delete |
|
delete |
|
private |
Definition at line 60 of file async_op.hpp.
|
private |
Definition at line 59 of file async_op.hpp.
|
private |
Definition at line 61 of file async_op.hpp.