Skip to content

Commit

Permalink
Improved implementation of the visit() function for parallel expression.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Sep 26, 2024
1 parent 8f5b460 commit 6f2f11c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/ast/expression/ParallelExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@

#include <functional>
#include <memory>
#include <mutex>
#include <thread>

DynamicObject ParallelExpression::visit(SymbolTable& symbols) {
std::thread task(
[this, expr = std::move(this->expression), sym = &symbols]() mutable {
std::bind([
this,
expr = std::move(this->expression),
sym = &symbols
]() mutable {
std::mutex mtx;
std::scoped_lock<std::mutex> lock(mtx);

expr->visit(*sym);
}
})
);

symbols.addParallelism(std::move(task));
Expand Down

0 comments on commit 6f2f11c

Please sign in to comment.