How do I get the returned void pointer of the function that I pass the pthread_create?
static void* pthread_sendRequest(void* name){
RequestChannel chan(*(string*) name, RequestChannel::CLIENT_SIDE);
string returnValue = chan.send_request("Hi");
return (void*) &returnValue;
}
pthread_create(thread, NULL, pthread_sendRequest, new string(&"worker #" [i]));
How do I get the return value, of pthread_sendRequest when it is passed to pthread_ create, so I can cast it back to a string pointer and get the actual string?
Does the void** in pthread_join(thread, void**) grab it for me?
returned valuefrom a thread function. If you need to exchange data between threads, use the parameters of the thread function. - πάντα ῥεῖstd::thread t{func, std::ref(returnedData)};and makefuncreturnvoidand take whatever data to return by reference. - chrisvoid*is too vague). - πάντα ῥεῖ