mirror of
https://github.com/lovell/sharp.git
synced 2025-07-13 12:20:13 +02:00
Upgrade nan dependency, enables async hooks
This commit is contained in:
parent
5ab6f599fb
commit
498b061819
@ -78,7 +78,7 @@
|
||||
"dependencies": {
|
||||
"color": "^3.0.0",
|
||||
"detect-libc": "^1.0.3",
|
||||
"nan": "^2.8.0",
|
||||
"nan": "^2.9.2",
|
||||
"semver": "^5.5.0",
|
||||
"simple-get": "^2.7.0",
|
||||
"tar": "^4.3.2",
|
||||
|
@ -27,7 +27,8 @@ class MetadataWorker : public Nan::AsyncWorker {
|
||||
MetadataWorker(
|
||||
Nan::Callback *callback, MetadataBaton *baton, Nan::Callback *debuglog,
|
||||
std::vector<v8::Local<v8::Object>> const buffersToPersist) :
|
||||
Nan::AsyncWorker(callback), baton(baton), debuglog(debuglog),
|
||||
Nan::AsyncWorker(callback, "sharp:MetadataWorker"),
|
||||
baton(baton), debuglog(debuglog),
|
||||
buffersToPersist(buffersToPersist) {
|
||||
// Protect Buffer objects from GC, keyed on index
|
||||
std::accumulate(buffersToPersist.begin(), buffersToPersist.end(), 0,
|
||||
@ -165,12 +166,12 @@ class MetadataWorker : public Nan::AsyncWorker {
|
||||
std::string warning = sharp::VipsWarningPop();
|
||||
while (!warning.empty()) {
|
||||
v8::Local<v8::Value> message[1] = { New(warning).ToLocalChecked() };
|
||||
debuglog->Call(1, message);
|
||||
debuglog->Call(1, message, async_resource);
|
||||
warning = sharp::VipsWarningPop();
|
||||
}
|
||||
|
||||
// Return to JavaScript
|
||||
callback->Call(2, argv);
|
||||
callback->Call(2, argv, async_resource);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -35,7 +35,8 @@ class PipelineWorker : public Nan::AsyncWorker {
|
||||
PipelineWorker(
|
||||
Nan::Callback *callback, PipelineBaton *baton, Nan::Callback *debuglog, Nan::Callback *queueListener,
|
||||
std::vector<v8::Local<v8::Object>> const buffersToPersist) :
|
||||
Nan::AsyncWorker(callback), baton(baton), debuglog(debuglog), queueListener(queueListener),
|
||||
Nan::AsyncWorker(callback, "sharp:PipelineWorker"),
|
||||
baton(baton), debuglog(debuglog), queueListener(queueListener),
|
||||
buffersToPersist(buffersToPersist) {
|
||||
// Protect Buffer objects from GC, keyed on index
|
||||
std::accumulate(buffersToPersist.begin(), buffersToPersist.end(), 0,
|
||||
@ -1014,18 +1015,18 @@ class PipelineWorker : public Nan::AsyncWorker {
|
||||
std::string warning = sharp::VipsWarningPop();
|
||||
while (!warning.empty()) {
|
||||
v8::Local<v8::Value> message[1] = { New(warning).ToLocalChecked() };
|
||||
debuglog->Call(1, message);
|
||||
debuglog->Call(1, message, async_resource);
|
||||
warning = sharp::VipsWarningPop();
|
||||
}
|
||||
|
||||
// Decrement processing task counter
|
||||
g_atomic_int_dec_and_test(&sharp::counterProcess);
|
||||
v8::Local<v8::Value> queueLength[1] = { New<v8::Uint32>(sharp::counterQueue) };
|
||||
queueListener->Call(1, queueLength);
|
||||
queueListener->Call(1, queueLength, async_resource);
|
||||
delete queueListener;
|
||||
|
||||
// Return to JavaScript
|
||||
callback->Call(3, argv);
|
||||
callback->Call(3, argv, async_resource);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1302,5 +1303,6 @@ NAN_METHOD(pipeline) {
|
||||
// Increment queued task counter
|
||||
g_atomic_int_inc(&sharp::counterQueue);
|
||||
v8::Local<v8::Value> queueLength[1] = { Nan::New<v8::Uint32>(sharp::counterQueue) };
|
||||
queueListener->Call(1, queueLength);
|
||||
v8::Local<v8::Object> recv = Nan::New<v8::Object>();
|
||||
Nan::Call(*queueListener, recv, 1, queueLength);
|
||||
}
|
||||
|
@ -28,7 +28,8 @@ class StatsWorker : public Nan::AsyncWorker {
|
||||
StatsWorker(
|
||||
Nan::Callback *callback, StatsBaton *baton, Nan::Callback *debuglog,
|
||||
std::vector<v8::Local<v8::Object>> const buffersToPersist) :
|
||||
Nan::AsyncWorker(callback), baton(baton), debuglog(debuglog),
|
||||
Nan::AsyncWorker(callback, "sharp:StatsWorker"),
|
||||
baton(baton), debuglog(debuglog),
|
||||
buffersToPersist(buffersToPersist) {
|
||||
// Protect Buffer objects from GC, keyed on index
|
||||
std::accumulate(buffersToPersist.begin(), buffersToPersist.end(), 0,
|
||||
@ -145,12 +146,12 @@ class StatsWorker : public Nan::AsyncWorker {
|
||||
std::string warning = sharp::VipsWarningPop();
|
||||
while (!warning.empty()) {
|
||||
v8::Local<v8::Value> message[1] = { New(warning).ToLocalChecked() };
|
||||
debuglog->Call(1, message);
|
||||
debuglog->Call(1, message, async_resource);
|
||||
warning = sharp::VipsWarningPop();
|
||||
}
|
||||
|
||||
// Return to JavaScript
|
||||
callback->Call(2, argv);
|
||||
callback->Call(2, argv, async_resource);
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user