Improve thread/buffer shutdown using new vips_thread_shutdown method - closes #5

This commit is contained in:
Lovell Fuller
2014-01-15 21:35:44 +00:00
parent f7b8ce1287
commit 7e8af63129
3 changed files with 10 additions and 2 deletions

View File

@@ -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);
};