Commit 17debd72 authored by Jérémy Lal's avatar Jérémy Lal

Imported Upstream version 2.3.0

parent 4260d6dc
# NAN ChangeLog
**Version 2.2.1: current Node 5.9.1, Node 12: 0.12.12, Node 10: 0.10.43, iojs: 3.3.1**
**Version 2.3.0: current Node 6.0.0, Node 12: 0.12.13, Node 10: 0.10.44, iojs: 3.3.1**
### 2.3.0 Apr 27 2016
- Feature: added Signal() for invoking async callbacks without sending data from AsyncProgressWorker d8adba45f20e077d00561b20199133620c990b38
- Bugfix: Don't use deprecated v8::Template::Set() 00dacf0a4b86027415867fa7f1059acc499dcece
### 2.2.1 Mar 29 2016
......
......@@ -35,6 +35,7 @@ LINT_SOURCES = \
test/cpp/accessors2.cpp \
test/cpp/asyncworker.cpp \
test/cpp/asyncprogressworker.cpp \
test/cpp/asyncprogressworkersignal.cpp \
test/cpp/asyncworkererror.cpp \
test/cpp/buffer.cpp \
test/cpp/bufferworkerpersistent.cpp \
......
Native Abstractions for Node.js
===============================
**A header file filled with macro and utility goodness for making add-on development for Node.js easier across versions 0.8, 0.10, 0.12, 4 and 5.**
**A header file filled with macro and utility goodness for making add-on development for Node.js easier across versions 0.8, 0.10, 0.12, 1, 4, 5 and 6.**
***Current version: 2.2.1***
***Current version: 2.3.0***
*(See [CHANGELOG.md](https://github.com/nodejs/nan/blob/master/CHANGELOG.md) for complete ChangeLog)*
......@@ -356,13 +356,32 @@ Modifications of the contents of the NAN repository are made on a collaborative
If a change proposal cannot reach a consensus, a WG member can call for a vote amongst the members of the WG. Simple majority wins.
### Developer's Certificate of Origin 1.0
<a id="developers-certificate-of-origin"></a>
## Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
* (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or
* (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or
* (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.
* (a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
* (b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
* (c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
* (d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
<a name="collaborators"></a>
### WG Members / Collaborators
......
......@@ -75,6 +75,7 @@ class AsyncProgressWorker : public AsyncWorker {
class ExecutionProgress {
public:
void Signal() const;
void Send(const char* data, size_t size) const;
};
......
......@@ -12,7 +12,7 @@
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
*
* Version 2.2.1: current Node 5.9.1, Node 12: 0.12.12, Node 10: 0.10.43, iojs: 3.3.1
* Version 2.3.0: current Node 6.0.0, Node 12: 0.12.13, Node 10: 0.10.44, iojs: 3.3.1
*
* See https://github.com/nodejs/nan for the latest update to this file
**********************************************************************************/
......@@ -1631,6 +1631,9 @@ class Callback {
class ExecutionProgress {
friend class AsyncProgressWorker;
public:
void Signal() const {
uv_async_send(that_->async);
}
// You could do fancy generics with templates here.
void Send(const char* data, size_t size) const {
that_->SendProgress_(data, size);
......@@ -1864,13 +1867,13 @@ NAN_INLINE void SetPrototypeMethod(
v8::Local<v8::FunctionTemplate> recv
, const char* name, FunctionCallback callback) {
HandleScope scope;
v8::Local<v8::Function> fn = GetFunction(New<v8::FunctionTemplate>(
v8::Local<v8::FunctionTemplate> t = New<v8::FunctionTemplate>(
callback
, v8::Local<v8::Value>()
, New<v8::Signature>(recv))).ToLocalChecked();
, New<v8::Signature>(recv));
v8::Local<v8::String> fn_name = New(name).ToLocalChecked();
recv->PrototypeTemplate()->Set(fn_name, fn);
fn->SetName(fn_name);
recv->PrototypeTemplate()->Set(fn_name, t);
t->SetClassName(fn_name);
}
//=== Accessors and Such =======================================================
......
{
"name": "nan",
"version": "2.2.1",
"description": "Native Abstractions for Node.js: C++ header for Node 0.8 -> 4 compatibility",
"version": "2.3.0",
"description": "Native Abstractions for Node.js: C++ header for Node 0.8 -> 6 compatibility",
"main": "include_dirs.js",
"repository": {
"type": "git",
......
......@@ -97,6 +97,10 @@
"target_name" : "asyncprogressworker"
, "sources" : [ "cpp/asyncprogressworker.cpp" ]
}
, {
"target_name" : "asyncprogressworkersignal"
, "sources" : ["cpp/asyncprogressworkersignal.cpp"]
}
, {
"target_name" : "nancallback"
, "sources" : [ "cpp/nancallback.cpp" ]
......
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
#ifndef _WIN32
#include <unistd.h>
#define Sleep(x) usleep((x)*1000)
#endif
#include <nan.h>
using namespace Nan; // NOLINT(build/namespaces)
class ProgressWorker : public AsyncProgressWorker {
public:
ProgressWorker(
Callback *callback
, Callback *progress
, int milliseconds
, int iters)
: AsyncProgressWorker(callback), progress(progress)
, milliseconds(milliseconds), iters(iters) {}
~ProgressWorker() {}
void Execute (const AsyncProgressWorker::ExecutionProgress& progress) {
for (int i = 0; i < iters; ++i) {
progress.Signal();
Sleep(milliseconds);
}
}
void HandleProgressCallback(const char *data, size_t size) {
HandleScope scope;
v8::Local<v8::Value> arg = New<v8::Boolean>(data == NULL && size == 0);
progress->Call(1, &arg);
}
private:
Callback *progress;
int milliseconds;
int iters;
};
NAN_METHOD(DoProgress) {
Callback *progress = new Callback(info[2].As<v8::Function>());
Callback *callback = new Callback(info[3].As<v8::Function>());
AsyncQueueWorker(new ProgressWorker(
callback
, progress
, To<uint32_t>(info[0]).FromJust()
, To<uint32_t>(info[1]).FromJust()));
}
NAN_MODULE_INIT(Init) {
Set(target
, New<v8::String>("a").ToLocalChecked()
, New<v8::FunctionTemplate>(DoProgress)->GetFunction());
}
NODE_MODULE(asyncprogressworkersignal, Init)
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
const test = require('tap').test
, testRoot = require('path').resolve(__dirname, '..')
, bindings = require('bindings')({ module_root: testRoot, bindings: 'asyncprogressworkersignal' });
test('asyncprogressworkersignal', function (t) {
var worker = bindings.a
, progressed = 0
worker(100, 5, function(i) {
t.ok(i === true, 'data being left at NULL');
progressed++;
}, function () {
t.ok(progressed === 5, 'got all progress updates')
t.end()
})
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment