Add multithreading tick
This commit is contained in:
@@ -10,7 +10,8 @@ Application::Application(Options options)
|
|||||||
: m_DryRun(options.dryrun.value()),
|
: m_DryRun(options.dryrun.value()),
|
||||||
m_Verbose(options.verbose.value()),
|
m_Verbose(options.verbose.value()),
|
||||||
m_BuildType(options.buildType.value()),
|
m_BuildType(options.buildType.value()),
|
||||||
m_Command(options.command) {
|
m_Command(options.command),
|
||||||
|
m_Multithreaded(options.multithreaded.value()) {
|
||||||
createAllLoggers();
|
createAllLoggers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +46,11 @@ void Application::save_graph(std::string filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Application::run() {
|
void Application::run() {
|
||||||
tf::Executor executor;
|
int numOfWorkers = 1;
|
||||||
|
// Default to 4 workers if multithreaded
|
||||||
|
if (m_Multithreaded) numOfWorkers = 4;
|
||||||
|
tf::Executor executor(numOfWorkers);
|
||||||
|
|
||||||
executor.run(m_Taskflow).wait();
|
executor.run(m_Taskflow).wait();
|
||||||
spdlog::get("app")->info("All work done!");
|
spdlog::get("app")->info("All work done!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class Application {
|
|||||||
private:
|
private:
|
||||||
bool m_DryRun;
|
bool m_DryRun;
|
||||||
bool m_Verbose;
|
bool m_Verbose;
|
||||||
|
bool m_Multithreaded;
|
||||||
BuildType m_BuildType;
|
BuildType m_BuildType;
|
||||||
Command m_Command;
|
Command m_Command;
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,11 @@ struct Options {
|
|||||||
|
|
||||||
std::optional<bool> verbose = false;
|
std::optional<bool> verbose = false;
|
||||||
std::optional<bool> dryrun = false;
|
std::optional<bool> dryrun = false;
|
||||||
|
std::optional<bool> multithreaded = false;
|
||||||
std::optional<std::string> graphFilename;
|
std::optional<std::string> graphFilename;
|
||||||
};
|
};
|
||||||
STRUCTOPT(Options, command, buildType, verbose, dryrun, graphFilename);
|
STRUCTOPT(Options, command, buildType, verbose, dryrun, multithreaded,
|
||||||
|
graphFilename);
|
||||||
|
|
||||||
Options parse(int argc, char** argv);
|
Options parse(int argc, char** argv);
|
||||||
|
|
||||||
|
|||||||
@@ -17,9 +17,6 @@ void Application::buildProject() {
|
|||||||
m_Taskflow.emplace([this]() { this->buildDir("build/debug"); })
|
m_Taskflow.emplace([this]() { this->buildDir("build/debug"); })
|
||||||
.name("buildDir(build/debug)");
|
.name("buildDir(build/debug)");
|
||||||
|
|
||||||
configureDirDebugTask.precede(buildDirDebugTask);
|
|
||||||
checkBuildDirsTask.precede(configureDirDebugTask);
|
|
||||||
|
|
||||||
auto configureDirReleaseTask =
|
auto configureDirReleaseTask =
|
||||||
m_Taskflow
|
m_Taskflow
|
||||||
.emplace([this]() {
|
.emplace([this]() {
|
||||||
@@ -30,9 +27,6 @@ void Application::buildProject() {
|
|||||||
m_Taskflow.emplace([this]() { this->buildDir("build/release"); })
|
m_Taskflow.emplace([this]() { this->buildDir("build/release"); })
|
||||||
.name("buildDir(build/release)");
|
.name("buildDir(build/release)");
|
||||||
|
|
||||||
configureDirReleaseTask.precede(buildDirReleaseTask);
|
|
||||||
checkBuildDirsTask.precede(configureDirReleaseTask);
|
|
||||||
|
|
||||||
auto configureDirRelWithDebTask =
|
auto configureDirRelWithDebTask =
|
||||||
m_Taskflow
|
m_Taskflow
|
||||||
.emplace([this]() {
|
.emplace([this]() {
|
||||||
@@ -43,9 +37,6 @@ void Application::buildProject() {
|
|||||||
m_Taskflow.emplace([this]() { this->buildDir("build/relwithdeb"); })
|
m_Taskflow.emplace([this]() { this->buildDir("build/relwithdeb"); })
|
||||||
.name("buildDir(build/relwithdeb)");
|
.name("buildDir(build/relwithdeb)");
|
||||||
|
|
||||||
configureDirRelWithDebTask.precede(buildDirRelWithDebTask);
|
|
||||||
checkBuildDirsTask.precede(configureDirRelWithDebTask);
|
|
||||||
|
|
||||||
auto configureDirMinSizeRelTask =
|
auto configureDirMinSizeRelTask =
|
||||||
m_Taskflow
|
m_Taskflow
|
||||||
.emplace([this]() {
|
.emplace([this]() {
|
||||||
@@ -56,8 +47,19 @@ void Application::buildProject() {
|
|||||||
m_Taskflow.emplace([this]() { this->buildDir("build/minsizerel"); })
|
m_Taskflow.emplace([this]() { this->buildDir("build/minsizerel"); })
|
||||||
.name("buildDir(build/minsizerel)");
|
.name("buildDir(build/minsizerel)");
|
||||||
|
|
||||||
configureDirMinSizeRelTask.precede(buildDirMinSizeRelTask);
|
configureDirDebugTask.succeed(checkBuildDirsTask);
|
||||||
checkBuildDirsTask.precede(configureDirMinSizeRelTask);
|
configureDirReleaseTask.succeed(checkBuildDirsTask);
|
||||||
|
configureDirRelWithDebTask.succeed(checkBuildDirsTask);
|
||||||
|
configureDirMinSizeRelTask.succeed(checkBuildDirsTask);
|
||||||
|
|
||||||
|
buildDirDebugTask.succeed(configureDirDebugTask);
|
||||||
|
buildDirReleaseTask.succeed(configureDirReleaseTask);
|
||||||
|
buildDirRelWithDebTask.succeed(configureDirRelWithDebTask);
|
||||||
|
buildDirMinSizeRelTask.succeed(configureDirMinSizeRelTask);
|
||||||
|
|
||||||
|
buildDirReleaseTask.succeed(buildDirDebugTask);
|
||||||
|
buildDirRelWithDebTask.succeed(buildDirReleaseTask);
|
||||||
|
buildDirMinSizeRelTask.succeed(buildDirRelWithDebTask);
|
||||||
|
|
||||||
} else if (m_BuildType == BuildType::debug) {
|
} else if (m_BuildType == BuildType::debug) {
|
||||||
auto configureDirTask =
|
auto configureDirTask =
|
||||||
|
|||||||
Reference in New Issue
Block a user