c++ asynchronous for-each and reduce operations