Naming (general purpose) thread-safe data structures?

那年仲夏 提交于 2019-12-07 00:45:28

问题


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 (or thingamajig_synchronized or synchronized_thingamajig)
  • Concurrent...
  • ThreadSafe...
  • Safe...
  • Parallel...
  • Locked...
  • Mutex ... or Mutexed...
  • 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?


回答1:


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.




回答2:


I think you should try this name:

SafeContainer



来源:https://stackoverflow.com/questions/17166268/naming-general-purpose-thread-safe-data-structures

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!