Trigger event loop more intelligently and automatically in libvitastor_c
This commit is contained in:
@@ -155,7 +155,9 @@ NAN_METHOD(NodeVitastor::Read)
|
||||
|
||||
self->Ref();
|
||||
vitastor_c_read(self->c, ((pool << (64-POOL_ID_BITS)) | inode), req->offset, req->len, &req->iov, 1, on_read_finish, req);
|
||||
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||
vitastor_c_uring_handle_events(self->c);
|
||||
#endif
|
||||
}
|
||||
|
||||
NodeVitastorRequest* NodeVitastor::get_write_request(const Nan::FunctionCallbackInfo<v8::Value> & info, int argpos)
|
||||
@@ -224,7 +226,9 @@ NAN_METHOD(NodeVitastor::Write)
|
||||
req->iov_list.size() ? req->iov_list.data() : &req->iov,
|
||||
req->iov_list.size() ? req->iov_list.size() : 1,
|
||||
on_write_finish, req);
|
||||
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||
vitastor_c_uring_handle_events(self->c);
|
||||
#endif
|
||||
}
|
||||
|
||||
NodeVitastorRequest* NodeVitastor::get_delete_request(const Nan::FunctionCallbackInfo<v8::Value> & info, int argpos)
|
||||
@@ -271,7 +275,9 @@ NAN_METHOD(NodeVitastor::Delete)
|
||||
self->Ref();
|
||||
vitastor_c_delete(self->c, ((pool << (64-POOL_ID_BITS)) | inode), req->offset, req->len, req->version,
|
||||
on_write_finish, req);
|
||||
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||
vitastor_c_uring_handle_events(self->c);
|
||||
#endif
|
||||
}
|
||||
|
||||
// sync(callback(err))
|
||||
@@ -288,7 +294,9 @@ NAN_METHOD(NodeVitastor::Sync)
|
||||
|
||||
self->Ref();
|
||||
vitastor_c_sync(self->c, on_write_finish, req);
|
||||
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||
vitastor_c_uring_handle_events(self->c);
|
||||
#endif
|
||||
}
|
||||
|
||||
// read_bitmap(pool, inode, offset, length, with_parents, callback(err, bitmap_buffer))
|
||||
@@ -310,7 +318,9 @@ NAN_METHOD(NodeVitastor::ReadBitmap)
|
||||
auto req = new NodeVitastorRequest(self, callback);
|
||||
self->Ref();
|
||||
vitastor_c_read_bitmap(self->c, ((pool << (64-POOL_ID_BITS)) | inode), offset, len, with_parents, on_read_bitmap_finish, req);
|
||||
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||
vitastor_c_uring_handle_events(self->c);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void on_error(NodeVitastorRequest *req, Nan::Callback & nanCallback, long retval)
|
||||
@@ -335,7 +345,9 @@ NAN_METHOD(NodeVitastor::OnReady)
|
||||
auto req = new NodeVitastorRequest(self, callback);
|
||||
self->Ref();
|
||||
vitastor_c_on_ready(self->c, on_ready_finish, req);
|
||||
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||
vitastor_c_uring_handle_events(self->c);
|
||||
#endif
|
||||
}
|
||||
|
||||
void NodeVitastor::on_ready_finish(void *opaque, long retval)
|
||||
@@ -480,7 +492,9 @@ NAN_METHOD(NodeVitastorImage::Create)
|
||||
img->Ref();
|
||||
cli->Ref();
|
||||
vitastor_c_watch_inode(cli->c, (char*)img->name.c_str(), on_watch_start, img);
|
||||
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||
vitastor_c_uring_handle_events(cli->c);
|
||||
#endif
|
||||
|
||||
info.GetReturnValue().Set(info.This());
|
||||
}
|
||||
@@ -621,7 +635,9 @@ void NodeVitastorImage::exec_request(NodeVitastorRequest *req)
|
||||
uint64_t ino = vitastor_c_inode_get_num(watch);
|
||||
cli->Ref();
|
||||
vitastor_c_read(cli->c, ino, req->offset, req->len, &req->iov, 1, NodeVitastor::on_read_finish, req);
|
||||
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||
vitastor_c_uring_handle_events(cli->c);
|
||||
#endif
|
||||
}
|
||||
else if (req->op == NODE_VITASTOR_WRITE)
|
||||
{
|
||||
@@ -631,7 +647,9 @@ void NodeVitastorImage::exec_request(NodeVitastorRequest *req)
|
||||
req->iov_list.size() ? req->iov_list.data() : &req->iov,
|
||||
req->iov_list.size() ? req->iov_list.size() : 1,
|
||||
NodeVitastor::on_write_finish, req);
|
||||
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||
vitastor_c_uring_handle_events(cli->c);
|
||||
#endif
|
||||
}
|
||||
else if (req->op == NODE_VITASTOR_DELETE)
|
||||
{
|
||||
@@ -639,7 +657,9 @@ void NodeVitastorImage::exec_request(NodeVitastorRequest *req)
|
||||
cli->Ref();
|
||||
vitastor_c_delete(cli->c, ino, req->offset, req->len, req->version,
|
||||
NodeVitastor::on_write_finish, req);
|
||||
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||
vitastor_c_uring_handle_events(cli->c);
|
||||
#endif
|
||||
}
|
||||
else if (req->op == NODE_VITASTOR_SYNC)
|
||||
{
|
||||
@@ -649,7 +669,9 @@ void NodeVitastorImage::exec_request(NodeVitastorRequest *req)
|
||||
if (imm != IMMEDIATE_ALL)
|
||||
{
|
||||
vitastor_c_sync(cli->c, NodeVitastor::on_write_finish, req);
|
||||
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||
vitastor_c_uring_handle_events(cli->c);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -661,7 +683,9 @@ void NodeVitastorImage::exec_request(NodeVitastorRequest *req)
|
||||
uint64_t ino = vitastor_c_inode_get_num(watch);
|
||||
cli->Ref();
|
||||
vitastor_c_read_bitmap(cli->c, ino, req->offset, req->len, req->with_parents, NodeVitastor::on_read_bitmap_finish, req);
|
||||
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||
vitastor_c_uring_handle_events(cli->c);
|
||||
#endif
|
||||
}
|
||||
else if (req->op == NODE_VITASTOR_GET_INFO)
|
||||
{
|
||||
@@ -793,7 +817,9 @@ NAN_METHOD(NodeVitastorKV::Open)
|
||||
delete req;
|
||||
kv->Unref();
|
||||
});
|
||||
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||
vitastor_c_uring_handle_events(kv->cli->c);
|
||||
#endif
|
||||
}
|
||||
|
||||
// close(callback(err))
|
||||
@@ -817,7 +843,9 @@ NAN_METHOD(NodeVitastorKV::Close)
|
||||
delete req;
|
||||
kv->Unref();
|
||||
});
|
||||
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||
vitastor_c_uring_handle_events(kv->cli->c);
|
||||
#endif
|
||||
}
|
||||
|
||||
// set_config({ ...config })
|
||||
@@ -876,7 +904,9 @@ void NodeVitastorKV::get_impl(const Nan::FunctionCallbackInfo<v8::Value> & info,
|
||||
delete req;
|
||||
kv->Unref();
|
||||
}, allow_cache);
|
||||
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||
vitastor_c_uring_handle_events(kv->cli->c);
|
||||
#endif
|
||||
}
|
||||
|
||||
// get(key, callback(err, value))
|
||||
@@ -949,7 +979,9 @@ NAN_METHOD(NodeVitastorKV::Set)
|
||||
delete cas_req;
|
||||
kv->Unref();
|
||||
}, cas_cb);
|
||||
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||
vitastor_c_uring_handle_events(kv->cli->c);
|
||||
#endif
|
||||
}
|
||||
|
||||
// del(key, callback(err), cas_compare(old_value)?)
|
||||
@@ -988,7 +1020,9 @@ NAN_METHOD(NodeVitastorKV::Del)
|
||||
delete cas_req;
|
||||
kv->Unref();
|
||||
}, cas_cb);
|
||||
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||
vitastor_c_uring_handle_events(kv->cli->c);
|
||||
#endif
|
||||
}
|
||||
|
||||
// list(start_key?)
|
||||
@@ -1109,7 +1143,9 @@ NAN_METHOD(NodeVitastorKVListing::Next)
|
||||
list->iter = req;
|
||||
list->kv->Unref();
|
||||
});
|
||||
#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
|
||||
vitastor_c_uring_handle_events(list->kv->cli->c);
|
||||
#endif
|
||||
}
|
||||
|
||||
// close()
|
||||
|
||||
Reference in New Issue
Block a user