What is the correct way to pass a C ++ object from one thread to another using boost :: thread?
1 answer
It depends solely on what the object is "doing". If it is self-contained, that is, it does not contain pointers / references to other objects that might be used in the original stream - there seems to be no problem. If OTOH in contains links to some data that can still be used in the original stream, its access must be synchronized.
And of course, you should avoid passing a complex object by value.
+1
source to share