Multithreaded deep copies

What is the best way to execute a deep copy in the constructor of an object that is part of multi-threaded C ++ code?

+3
source share
3 answers

Depends on your data structures.

I assume that the problem you are facing (although you are not saying this) is a potential inverse of blocking. If you are copying deeply, you are likely to take one or more locks for the various objects that you need to copy.

DAG ( ), ​​, , , , , . , , . , " " , .

"WidgetBoxes", "", , , , . , WidgetBox ( " " ), , . , , . .

, WidgetBoxes. , , , .

, . , , , WidgetBox, ( - - - , , " " , , ), WidgetBox, . , . , , WidgetBox , , , . , .

, "" - . , ( ).

, , , . , -, , , .

+4

()

. : "

, onebyone . , , , ...

0

( ):

Lock this object, which the code uses for writing. When you deep copy, lock the object, make your deep copy, and then unlock it.

Or am I missing something here?

-1
source

Source: https://habr.com/ru/post/1697959/


All Articles