node.js binding fixes

This commit is contained in:
Vitaliy Filippov
2024-08-04 15:54:20 +03:00
parent eb3e8b8c19
commit e1a0e89a6b
5 changed files with 192 additions and 95 deletions
+11 -7
View File
@@ -36,6 +36,7 @@ private:
uv_poll_t poll_watcher;
// FIXME: Is it really needed?
std::mutex mu;
std::vector<std::function<void()>> postponed;
NodeVitastor();
@@ -44,6 +45,14 @@ private:
static void on_write_finish(void *opaque, long retval);
static void on_read_bitmap_finish(void *opaque, long retval, uint8_t *bitmap);
void run_postponed();
static void postpone_read_finish(void *opaque, long retval, uint64_t version);
static void postpone_write_finish(void *opaque, long retval);
static void postpone_read_bitmap_finish(void *opaque, long retval, uint8_t *bitmap);
NodeVitastorRequest* get_read_request(const Nan::FunctionCallbackInfo<v8::Value> & info, int argpos);
NodeVitastorRequest* get_write_request(const Nan::FunctionCallbackInfo<v8::Value> & info, int argpos);
friend class NodeVitastorImage;
friend class NodeVitastorKV;
friend class NodeVitastorKVListing;
@@ -74,11 +83,10 @@ private:
std::vector<NodeVitastorRequest*> on_init;
Nan::Persistent<v8::Object> cliObj;
NodeVitastorImage();
static void on_watch_start(void *opaque, long retval);
void exec_request(NodeVitastorRequest *req);
void exec_or_wait(NodeVitastorRequest *req);
void fill_info(v8::Local<v8::Object> & res);
};
class NodeVitastorKV: public Nan::ObjectWrap
@@ -86,7 +94,7 @@ class NodeVitastorKV: public Nan::ObjectWrap
public:
// constructor(node_vitastor)
static NAN_METHOD(Create);
// open(inode_id, { ...config }, callback(err))
// open(pool_id, inode_num, { ...config }, callback(err))
static NAN_METHOD(Open);
// set_config({ ...config })
static NAN_METHOD(SetConfig);
@@ -113,8 +121,6 @@ private:
NodeVitastor *cli = NULL;
vitastorkv_dbw_t *dbw = NULL;
NodeVitastorKV();
static void get_impl(const Nan::FunctionCallbackInfo<v8::Value> & info, bool allow_cache);
friend class NodeVitastorKVListing;
@@ -135,8 +141,6 @@ public:
private:
NodeVitastorKV *kv = NULL;
void *handle = NULL;
NodeVitastorKVListing();
};
#endif