Use the deferred policy when --parallel isn't present.
This commit is contained in:
parent
61946b891f
commit
87de5ca3f4
13
src/main.cpp
13
src/main.cpp
|
@ -28,10 +28,11 @@ int main(int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
if (!files.empty()) {
|
if (!files.empty()) {
|
||||||
const set<string_view> uniqueFiles(files.begin(), files.end());
|
const set<string_view> uniqueFiles(files.begin(), files.end());
|
||||||
vector<future<string>> units;
|
vector<future<string>> Units;
|
||||||
for (string_view fileName: uniqueFiles) {
|
for (string_view fileName: uniqueFiles) {
|
||||||
if (fileName != "none") {
|
if (fileName != "none") {
|
||||||
future<string> newAsync = async(launch::async, [printResult, fileName, target]() mutable {
|
const launch Policy = !parallel ? launch::deferred : launch::async;
|
||||||
|
future<string> newAsync = async(Policy, [printResult, fileName, target]() mutable {
|
||||||
const string transpiledString = transpile(parseString(getFileContent(fileName.data())), target);
|
const string transpiledString = transpile(parseString(getFileContent(fileName.data())), target);
|
||||||
stringstream consoleOutput;
|
stringstream consoleOutput;
|
||||||
if (printResult) consoleOutput << "~~~~[Yerbacon compilation result]~~~~\n\n" << "[WIP]\n" << transpiledString << "\n\n";
|
if (printResult) consoleOutput << "~~~~[Yerbacon compilation result]~~~~\n\n" << "[WIP]\n" << transpiledString << "\n\n";
|
||||||
|
@ -41,14 +42,10 @@ int main(int argc, char* argv[]) {
|
||||||
outputFileContent(outputFile, transpiledString);
|
outputFileContent(outputFile, transpiledString);
|
||||||
return consoleOutput.str();
|
return consoleOutput.str();
|
||||||
});
|
});
|
||||||
if (!parallel) cout << newAsync.get(); else {
|
Units.push_back(move(newAsync));
|
||||||
units.push_back(move(newAsync));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto& currentThread: units) {
|
for (auto& currentFuture: Units) cout << currentFuture.get();
|
||||||
cout << currentThread.get();
|
|
||||||
}
|
|
||||||
} else cout << "No valid file provided.\n";
|
} else cout << "No valid file provided.\n";
|
||||||
}
|
}
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
Loading…
Reference in New Issue