W
W
wally2021-09-21 21:21:02
C++ / C#
wally, 2021-09-21 21:21:02

Best practice ThreadSafe queue implementation for C++?

I am implementing a simple multi-threaded program with multiple producers, single consumer. MSVC toolchain. You need a thread-safe queue. In the STL, the queue class is not threadsafe. While implemented through one global Lock on read and write operations. What is the best way to implement such functionality in a normal and without tangible damage to performance? Heard about libcds but don't want to use 3rd party libraries, only STL

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Armenian Radio, 2021-09-21
@Yum1

Best Practice - don't use lisaped collective farms when libcds or facebook/folly
LockFree container is nearby, which is asked here as a solution, it's very hard to write and even harder to debug.
That is, you should do this only if you want to learn how to write LockFree solutions yourself and have one - two - three months of time for this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question