#include #include #include "nan.h" #include "common.h" #include "utilities.h" using v8::Local; using v8::Object; using v8::Number; using v8::String; using sharp::counterQueue; using sharp::counterProcess; /* Get and set cache memory and item limits */ NAN_METHOD(cache) { NanScope(); // Set cache memory limit if (args[0]->IsInt32()) { int newMax = args[0]->Int32Value() * 1048576; int oldMax = vips_cache_get_max_mem(); vips_cache_set_max_mem(newMax); // Notify the V8 garbage collector of delta in max cache size NanAdjustExternalMemory(newMax - oldMax); } // Set cache items limit if (args[1]->IsInt32()) { vips_cache_set_max(args[1]->Int32Value()); } // Get cache statistics Local cache = NanNew(); cache->Set(NanNew("current"), NanNew(vips_tracked_get_mem() / 1048576)); cache->Set(NanNew("high"), NanNew(vips_tracked_get_mem_highwater() / 1048576)); cache->Set(NanNew("memory"), NanNew(vips_cache_get_max_mem() / 1048576)); cache->Set(NanNew("items"), NanNew(vips_cache_get_max())); NanReturnValue(cache); } /* Get and set size of thread pool */ NAN_METHOD(concurrency) { NanScope(); // Set concurrency if (args[0]->IsInt32()) { vips_concurrency_set(args[0]->Int32Value()); } // Get concurrency NanReturnValue(NanNew(vips_concurrency_get())); } /* Get internal counters (queued tasks, processing tasks) */ NAN_METHOD(counters) { NanScope(); Local counters = NanNew(); counters->Set(NanNew("queue"), NanNew(counterQueue)); counters->Set(NanNew("process"), NanNew(counterProcess)); NanReturnValue(counters); } /* Get libvips version */ NAN_METHOD(libvipsVersion) { NanScope(); char version[9]; snprintf(version, sizeof(version), "%d.%d.%d", vips_version(0), vips_version(1), vips_version(2)); NanReturnValue(NanNew(version)); }