1
0
Fork 0

Codefix: potential check of thread-shared field evades lock acquisition

pull/13818/head
Rubidium 2025-03-14 20:08:24 +01:00
parent ac2087a3eb
commit f57b6248a1
1 changed files with 2 additions and 2 deletions

View File

@ -191,8 +191,8 @@ public:
*/
inline void Push(const Titem &item)
{
std::lock_guard<std::mutex> lock(SmallStack::GetPool().GetMutex());
if (this->value != Tinvalid) {
std::lock_guard<std::mutex> lock(SmallStack::GetPool().GetMutex());
Tindex new_item = SmallStack::GetPool().Create();
if (new_item != Tmax_size) {
PooledSmallStack &pushed = SmallStack::GetPool().Get(new_item);
@ -211,11 +211,11 @@ public:
*/
inline Titem Pop()
{
std::lock_guard<std::mutex> lock(SmallStack::GetPool().GetMutex());
Titem ret = this->value;
if (this->next == Tmax_size) {
this->value = Tinvalid;
} else {
std::lock_guard<std::mutex> lock(SmallStack::GetPool().GetMutex());
PooledSmallStack &popped = SmallStack::GetPool().Get(this->next);
this->value = popped.value;
if (popped.branch_count == 0) {