命名(通用)线程安全数据结构? [英] Naming (general purpose) thread-safe data structures?
问题描述
我正在寻找一个好名字,以赋予线程安全/内部同步的数据结构.
C ++标准使用术语atomic
,但是 atomic具有一些相当特殊的含义. Microsoft在其线程安全集合中使用了术语Concurrent
(或在并行容器中的C ++ _concurrent
中).>
我真正想要的是(值)类型的通用包装,该包装提供与std :: atomics相似的一组操作,但是名称不同,并从中派生一些typedef. (用例:类似于 std :: atomic for std :: string )
您认为以下哪项有用/无效?为什么?
-
SynchronizedThingamajig
(或thingamajig_synchronized
或synchronized_thingamajig
) -
Concurrent...
-
ThreadSafe...
-
Safe...
-
Parallel...
-
Locked...
-
Mutex
...或Mutexed...
-
Multithreaded...
对于我给出的字符串示例,也许synchronized_string
或concurrent_string
最有意义,还是与其他任何含义冲突?
评论的有用答案:
Microsoft PPL和Intel TBB均使用
concurrent_*
.我唯一的 建议是:当您表示并发时不要使用并行. (平行线 是一种并发,但是这些数据结构甚至可以正常工作 在一个处理器上对多个线程进行时分多路复用.)您可能 还可以查看监视模式.
-6月18日12:02徘徊的逻辑
在进一步思考之后,我可能会从我给出的选择中补充一点,只有concurrent
和synchronized
才有意义.
I'm looking for a good name to give to data structures that are thread safe / internally synchronized.
The C++ standard uses the term atomic
, but atomic has some rather special meaning. Microsoft uses the term Concurrent
in their Thread-Safe Collections (or in C++ _concurrent
in the Parallel Containers).
What I really would like would be a generic wrapper for (value) types that provides a similar set of operations to what std::atomics do, but with a different name, and some typedefs derived from it. (use case: something like std::atomic for std::string)
Which of the following would you consider useful / not useful and why?
SynchronizedThingamajig
(orthingamajig_synchronized
orsynchronized_thingamajig
)Concurrent...
ThreadSafe...
Safe...
Parallel...
Locked...
Mutex
... orMutexed...
Multithreaded...
For the string example I gave, maybe a synchronized_string
or a concurrent_string
would make most sense, or would that clash with any other connotation?
Useful answer from comment:
Both Microsoft PPL and Intel TBB use
concurrent_*
. My only suggestion is: Don't use parallel when you mean concurrent. (Parallel is one kind of concurrency, but these data structures should work even on a single processor time-multiplexing multiple threads.) You might also look at the monitor pattern.
-- Wandering Logic Jun 18 at 12:02
To which I might add that from the choices I gave, after thinking some more about it, only concurrent
and synchronized
seem to make sense.
这篇关于命名(通用)线程安全数据结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!