Skip to content

Commit

Permalink
Added mutex into shared context
Browse files Browse the repository at this point in the history
  • Loading branch information
GrigoriyPA committed Nov 12, 2024
1 parent 89e7ba4 commit e1ffce2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ydb/core/fq/libs/row_dispatcher/common.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "common.h"

#include <util/system/mutex.h>

#include <ydb/library/yql/public/purecalc/common/interface.h>

namespace NFq {
Expand All @@ -9,22 +11,21 @@ namespace {
class TPureCalcProgramFactory : public IPureCalcProgramFactory {
public:
NYql::NPureCalc::IProgramFactoryPtr GetFactory(const TSettings& settings) override {
TGuard<TMutex> guard(FactoriesMutex);

const auto it = ProgramFactories.find(settings);
if (it != ProgramFactories.end()) {
return it->second;
}
return CreateFactory(settings);
}

private:
NYql::NPureCalc::IProgramFactoryPtr CreateFactory(const TSettings& settings) {
return ProgramFactories.insert({settings, NYql::NPureCalc::MakeProgramFactory(
NYql::NPureCalc::TProgramFactoryOptions()
.SetLLVMSettings(settings.EnabledLLVM ? "ON" : "OFF")
)}).first->second;
}

private:
TMutex FactoriesMutex;
std::map<TSettings, NYql::NPureCalc::IProgramFactoryPtr> ProgramFactories;
};

Expand Down

0 comments on commit e1ffce2

Please sign in to comment.