From 5c1780a9affa6c656f3da005e56f3b5c5a63df3d Mon Sep 17 00:00:00 2001 From: Username404 Date: Tue, 1 Nov 2022 11:01:34 +0100 Subject: [PATCH] main.cpp: Set the number of threads used by OpenMP to one when parallel is false Signed-off-by: Username404 --- src/main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a96e7e9..b5993ee 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,7 +38,10 @@ int main(int argc, char* argv[]) { } else goto invalid_argument; } else if (currentArgument == ArgumentShort("text")) printResult = text_provided = true; - else if (text_provided || currentArgument.ends_with(".ybcon")) + else if (text_provided || currentArgument.ends_with(".ybcon")) { + #ifdef _OPENMP + if (not parallel) omp_set_num_threads(1); + #endif Units.insert_or_assign(currentArgument, async(not parallel ? launch::deferred : launch::async, [currentArgument, &text_provided, &target, &newLines]() { unit_result resultingPair; try { @@ -61,7 +64,7 @@ int main(int argc, char* argv[]) { } return resultingPair; })); - else { + } else { if (argc == 2) { if (currentArgument == Argument("version")) { cout << Yerbacon::getVersion();