I am trying to write a nodejs bindings for a C++ library and I seem to have hit a roadblock.
I am working on trying to make all the calls to the C++ library asynchronous and thats why I am using libuv
. I am basically following this tutorial.
I want to be able to call class member functions from libuv's uv_queue_work
. Have a look at this code --
class test {
private:
int data;
void Work(uv_work_t *req);
void After(uv_work_t *req);
public:
Handle<Value> Async(const Arguments& args) {
HandleScope scope;
Local<Function> callback = Local<Function>::Cast(args[0]);
int status = uv_queue_work(uv_default_loop(), **something**, Work, After);
assert(status == 0);
return Undefined();
}
};
Basically I expect the Work
and After
functions to work on the data
element of the class. However this doesnt seem to work. I have tried typecasting the pointers to Work
and After
after from type void test::(*)(uv_work_t*)
to void (*)(uv_work_t*)
. But that also doesnt seem to work.
Could you guys give me some tips on how to work around this??