Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Need thread safe wel tested containers (non microsoft)

Any one having idea about thread safe data containers like queue, map? I dont want threadsafe STL when we use /MT switches for compiler.

A real thread safe wel tested STL containers.

like image 705
Vijay Avatar asked Dec 07 '25 04:12

Vijay


1 Answers

Thread safe containers usually make no sense. Consider a 'thread-safe` queue:

if(!qu.empty())
{
    // 1
    qu.pop();
}

What if during #1 the queue is modified and it becomes empty? It breaks the code. This is why you should use locks in your code rather than 'thread-safe' containers.

like image 125
Yakov Galka Avatar answered Dec 08 '25 16:12

Yakov Galka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!