Fix: set BT object's shared flag in all modes
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 5 Jun 2018 21:43:28 +0000 (17:43 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 2 May 2019 04:05:45 +0000 (00:05 -0400)
commitcdc4693da047ef54d55bf17d803605e4880b734e
tree3f8ba7378192f940ee30362b772620c41e12a3f0
parentafe86a0632768e5770e15a56261df2b874e2287c
Fix: set BT object's shared flag in all modes

Issue
=====
The bt_object_set_is_shared() function is only effective in a developer
mode build. Since the shared flag is 0 when allocated, and
bt_object_init() calls bt_object_set_is_shared() to make the object
shared initially, all objects are non-shared in non-developer mode.

This was the initial goal, because the only purpose of this shared
flag was to check if the developer is calling bt_get() or bt_put()
with a non-shared object. This check is only performed in developer
mode anyway. However, the object pool system resets the object's
reference count to 1 only when it is shared.

Solution
========
Make bt_object_set_is_shared() always effective, and make the object
pool unconditionally reset the reference count to 1 when recycling. This
avoids a check and the reference count is always 1 for a unique object
anyway (the test was superfluous).

I leave bt_object_set_is_shared() to be always enabled for future use
cases: it does not cost a lot to have it executed in non-developer mode
as its execution cost is amortized anyway for recycled objects.

Known drawbacks
===============
Unnoticeable performance impact.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
include/babeltrace/object-internal.h
include/babeltrace/object-pool-internal.h
This page took 0.024606 seconds and 4 git commands to generate.