Constructors C ++ and concurrency

I was thinking of writing a container class to control access to a complex data structure that will be used in a multi-threaded environment.

And then the question arose:

Is there ever a situation where C ++ constructors should be thread safe?

+5
source share
3 answers

Not in my experience. This is code that calls the constructor, implicitly or otherwise, that should be thread safe if the application requires it.

, , ( , ).

: , . , , , , "" .

, , , ( , , , - ).

+2

. , , , .

+4

, . , , . , , , , , .

You cannot create the same object in more than one thread at once, because each object is created only once, so there is no way to refer to the constructor on the same object more than once, and even more so to two different threads in the same time.

+3
source

All Articles