Skip to content

Commit

Permalink
Mutex lock for each SymbolTable instance.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Sep 27, 2024
1 parent 80a4aef commit e47deda
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions include/core/SymbolTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <functional>
#include <memory>
#include <mutex>
#include <thread>
#include <unordered_map>
#include <vector>
Expand All @@ -33,17 +34,20 @@ class SymbolTable {
SymbolTable* parent;
std::unordered_map<std::string, DynamicObject> table;
std::vector<std::thread> threads;
mutable std::mutex mtx;

public:
explicit SymbolTable(SymbolTable* _parent = nullptr) :
parent(_parent),
table({}),
threads() {}
threads(),
mtx() {}

explicit SymbolTable(const SymbolTable& other) :
parent(std::move(other.parent)),
table(std::move(other.table)),
threads() {}
threads(),
mtx() {}

SymbolTable& operator=(const SymbolTable& other);

Expand Down

0 comments on commit e47deda

Please sign in to comment.