-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
Line 142 in 389ceea
| static std::map<TransferImpl*, std::weak_ptr<TransferImpl>> m_TransferMap; |
This field is static. Access to change it is shared by all objects of the class. Creating multiple objects in different threads results in a data race.
Please use a mutex and encapsulate operations with this field.
Example:
using TransferStorage = std::map<TransferImpl*, std::weak_ptr<TransferImpl>>;
static TransferStorage m_TransferMap;
static std::mutex m_TransferMap_mutex;
template<class T>
static std::pair<TransferStorage::iterator, bool> insert_transfer(T&& value) {
std::lock_guard<std::mutex> lk(m_TransferMap_mutex);
return m_TransferMap.insert(std::move(value));
}
static size_t erase_transfer(TransferImpl* index) {
std::lock_guard<std::mutex> lk(m_TransferMap_mutex);
return m_TransferMap.erase(index);
}
static std::weak_ptr<TransferImpl> get_transfer(TransferImpl* index) {
std::lock_guard<std::mutex> lk(m_TransferMap_mutex);
return m_TransferMap[index];
}
Metadata
Metadata
Assignees
Labels
No labels