So, as you understand, you cannot directly call member functions.
The second argument is something "of type uv_work_t, which has the element" void * data ".
What you need to do is create static methods inside your class for "Work" and "After", create a uv_work_t structure and assign the data "this".
After this is done inside your static "Work" and "After" methods, you perform a static conversion to "req-> data" (To your class type), and then call your member functions.
For instance:
uv_work_t* baton = new uv_work_t(); baton->data = this; int status = uv_queue_work(uv_default_loop(), baton, StaticWork, StaticAfter);
And then in static methods
test* myobj = static_cast<test>(req->data); myobj->Work();
And similar code for StaticAfter function
source share