MCPcopy Create free account
hub / github.com/nodejs/node-addon-api / EchoWorker

Class EchoWorker

test/async_worker.cc:202–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200};
201
202class EchoWorker : public AsyncWorker {
203 public:
204 EchoWorker(Function& cb, std::string& echo) : AsyncWorker(cb), echo(echo) {}
205 ~EchoWorker() {}
206
207 void Execute() override {
208 // Simulate cpu heavy task
209 std::this_thread::sleep_for(std::chrono::milliseconds(30));
210 }
211
212 void OnOK() override {
213 HandleScope scope(Env());
214 Callback().Call({Env().Null(), String::New(Env(), echo)});
215 }
216
217 private:
218 std::string echo;
219};
220
221class FailCancelWorker : public AsyncWorker {
222 private:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected