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

Class ProgressWorker

test/cpp/asyncprogressworker.cpp:15–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected