Add "share_private" argument to copy constructor #11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The smart pointer C++ reference counting utilized by the DBus::Private
_pvt pointer isn't thread safe, so sharing/copying DBus:Message
instances across threads leads to crashes/DBus C library asserts as
Private pointer objects are released prematurely.
Rather than trying to make the reference counting itself thread-safe,
and slowing down single threaded usage, a share_private optional
argument is added the copy constructor. The share_private argument
defaults to true, which preserves the existing behavior of sharing the
Private* and associated reference counting.
If the share_private copy constructor argument is instead given as
false, a new instance is created with a new Private _pvt pointer and
unique reference count, which is logically "divorced" from the
original except that is refers to the same C DBus library pointer.
Note that the C DBus library handles its reference counting in
a thread safe manner.
This new object can then be utilized by another thread without
affecting the reference counting of the original.