I am new to threads and async functions and I am trying use async function to return information from the function below:
std::vector<std::vector<int> > calculatingSlices(SquareMatrix A, std::vector<std::vector<int> > slices)
and I am doing this using the following code:
std::vector<std::vector<int>> slices;
std::vector<std:future<std::vector<int>>> results;
for(int i = 0; i < numOfThreads; i++){
results.push_back(std::async(std::launch::async, calculatingSlices, A, slices))
}
I am getting this error though:
error: attempt to use a deleted function
So I guess my initial question is how do you declare an async function?
I also have a few questions about how async functions work. If you're declaring a number of async functions in a loop, like I have done above, will these all run simultaneously? or will they run one at a time as it progresses through the loop?
If they run one at a time, what would be a better way to run this function simultaneously amongst a varying number of threads?