Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::vector<std::thread> loader_threads;
- loader_threads.reserve(surfs.size());
- std::mutex surf_lock;
- for(const auto& f : file_paths) {
- loader_threads.emplace_back([&surf_lock, &surfs](const std::string path) {
- surface temp = image::get_image(path);
- std::lock_guard<std::mutex> lock(surf_lock);
- if(!temp.null()) {
- surfs.push_back({ std::move(temp), path});
- }
- }, f);
- }
- for(auto& thread : loader_threads) {
- thread.join();
- }
Advertisement
Add Comment
Please, Sign In to add comment