lundi 27 novembre 2017

return an array of structs from a function executed by a thread

I have an array of structure of 2 strings which I return from a function. But this function is called as part of the callable function of a thread

struct mystruct* myfunc(char* param1, int param2, int param3);

std::thread t1(myfunc, param1, param2, param3);

I understood from the std::thread documentation that the return value from myfunc will be ignored. But I need this data. Is there a way to get this data? I read there is something like std::promise and std::future but really couldn't understand what they are. Can anyone help me out with a simple example to achieve this?

Thanks a lot, in advance.

Esash

Aucun commentaire:

Enregistrer un commentaire