MCPcopy Create free account
hub / github.com/nodejs/nan / ProgressQueueWorker

Class ProgressQueueWorker

test/cpp/asyncprogressqueueworker.cpp:13–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11using namespace Nan; // NOLINT(build/namespaces)
12
13class ProgressQueueWorker : public AsyncProgressQueueWorker<char> {
14 public:
15 ProgressQueueWorker(
16 Callback *callback
17 , Callback *progress
18 , int iters)
19 : AsyncProgressQueueWorker(callback), progress(progress)
20 , iters(iters) {}
21
22 ~ProgressQueueWorker() {
23 delete progress;
24 }
25
26 void Execute (const AsyncProgressQueueWorker::ExecutionProgress& progress) {
27 for (int i = 0; i < iters; ++i) {
28 progress.Send(reinterpret_cast<const char*>(&i), sizeof(int));
29 }
30 }
31
32 void HandleProgressCallback(const char *data, size_t count) {
33 HandleScope scope;
34
35 v8::Local<v8::Value> argv[] = {
36 New<v8::Integer>(*reinterpret_cast<int*>(const_cast<char*>(data)))
37 };
38 progress->Call(1, argv, async_resource);
39 }
40
41 private:
42 Callback *progress;
43 int iters;
44};
45
46NAN_METHOD(DoProgress) {
47 Callback *progress = new Callback(To<v8::Function>(info[1]).ToLocalChecked());

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected