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

Function runAsync

examples/async_pi_estimate/addon.js:28–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26}
27
28function runAsync() {
29 // how many batches should we split the work in to?
30 var batches = process.argv[3] || 16;
31 var ended = 0;
32 var total = 0;
33 var start = Date.now();
34
35 function done (err, result) {
36 total += result;
37
38 // have all the batches finished executing?
39 if (++ended === batches) {
40 printResult('Async', total / batches, Date.now() - start);
41 }
42 }
43
44 // for each batch of work, request an async Estimate() for
45 // a portion of the total number of calculations
46 for (var i = 0; i < batches; i++) {
47 addon.calculateAsync(calculations / batches, done);
48 }
49}
50
51runSync();
52runAsync();

Callers 1

addon.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected