mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Improve thread/buffer shutdown using new vips_thread_shutdown method - closes #5
This commit is contained in:
@@ -160,6 +160,7 @@ void ResizeAsync(uv_work_t *work) {
|
||||
} else {
|
||||
(baton->err).append("Unsupported output file type");
|
||||
}
|
||||
vips_thread_shutdown();
|
||||
}
|
||||
|
||||
void ResizeAsyncAfter(uv_work_t *work, int status) {
|
||||
@@ -176,6 +177,7 @@ void ResizeAsyncAfter(uv_work_t *work, int status) {
|
||||
// Buffer
|
||||
Buffer *buffer = Buffer::New((const char*)(baton->buffer_out), baton->buffer_out_len);
|
||||
argv[1] = Local<Object>::New(buffer->handle_);
|
||||
vips_free(baton->buffer_out);
|
||||
}
|
||||
|
||||
baton->callback->Call(Context::GetCurrent()->Global(), 2, argv);
|
||||
@@ -210,9 +212,15 @@ Handle<Value> Resize(const Arguments& args) {
|
||||
return Undefined();
|
||||
}
|
||||
|
||||
static void at_exit(void* arg) {
|
||||
HandleScope scope;
|
||||
vips_shutdown();
|
||||
}
|
||||
|
||||
extern "C" void init(Handle<Object> target) {
|
||||
HandleScope scope;
|
||||
vips_init("");
|
||||
AtExit(at_exit);
|
||||
NODE_SET_METHOD(target, "resize", Resize);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user