Add bt2::internal::SharedObj::create{With,Without}Ref() methods
It seems like there were some confusion regarding the reference
acquisition of the `bt2::internal::SharedObj` constructor vs. its
createWithInitialRef() static method.
Make it clear with a private constructor and two public static methods:
* createWithoutRef() creates a shared object without getting a
reference.
* createWithRef() creates a shared object, immediately getting a new
reference.
Both methods have two versions: one which accepts a wrapper and one
which accepts a raw libbabeltrace2 pointer.
Update all the `src/cpp-common/bt2` code to use those methods.
The pattern for a non-static shared() method is:
Shared shared() const noexcept
{
return Shared::createWithRef(*this);
}
This means if you have a borrowed wrapper `obj`, then `obj.shared()`
returns a shared object, incrementing the reference count.
The pattern for a creation method is:
return Shared::createWithoutRef(libObjPtr);
where `libObjPtr` is a raw libbabeltrace2 pointer to an object of which
the reference count is one.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ifeef4af74a0078c1b7e9e5dfec8ebd5be381da8f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8039
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10797
Tested-by: jenkins <jenkins@lttng.org>
This page took 0.025336 seconds and 4 git commands to generate.