简体   繁体   English

C ++需要线程安全的测试容器(非微软)

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

Any one having idea about thread safe data containers like queue, map? 任何人都有关于线程安全数据容器的想法,比如queue,map? I dont want threadsafe STL when we use /MT switches for compiler. 当我们使用/ MT开关进行编译时,我不想要线程安全的STL。

A real thread safe wel tested STL containers. 真正的线程安全测试STL容器。

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? 如果在#1期间队列被修改并且它变空了怎么办? It breaks the code. 它破坏了代码。 This is why you should use locks in your code rather than 'thread-safe' containers. 这就是为什么你应该在你的代码,而不是“线程安全的”容器使用锁。

英特尔TBB专为此而设计。

/ MT暗示您想要链接到多线程运行时库(与多线程应用程序兼容),但它不会使运行时库是线程安全的。

Microsoft并行模式库(PPL)包括concurrent_vectorconcurrent_queue并且它们将并发运行时样本包v0.33及更高版本的unordered_mapunordered_multimapunordered_setunordered_multiset的并发版本添加。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM