开发者

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 compi开发者_运维百科ler.

A real thread safe wel tested STL containers.


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.


Intel TBB is specifically designed for this.


/MT imply you want to link to multithreaded runtime library (which is compatible to multithreaded application), but it does not make the runtime library is thread safe.


The Microsoft Parallel Patterns Library (PPL) includes concurrent_vector and concurrent_queue and they added concurrent versions of unordered_map, unordered_multimap, unordered_set, and unordered_multiset to the Concurrency Runtime sample pack v0.33 and newer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜