lib: update and simplify the `bt_object` API
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 12 Jun 2018 19:47:05 +0000 (15:47 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 2 May 2019 04:05:45 +0000 (00:05 -0400)
commit3fea54f69edd1780566230255da196cb6e82df62
treeec2ebf3c0f952ec32300278308bb35a2a8219c49
parentbaa56d0a4425a4865c638faaed4728ece07d59c7
lib: update and simplify the `bt_object` API

This patch merges `ref-internal.h` into `object-internal.h` so as to
simplify the `bt_object` API and ease the future addition of specialized
inline functions (e.g., no specific checks).

Notable changes:

* There's no specific reference count structure; the reference count is
  directly within `struct bt_object`.

* Most functions of `object-internal.h` accept and return the
  `struct bt_object *` type instead of `void *`.

* The `struct bt_object` structure contains two release function:

  `release_func`:
      Called when the reference count falls to zero by the new
     bt_object_put_no_null_check() function.

  `spec_release_func`:
      Called by bt_object_try_spec_release() (formerly
     bt_object_release()).

* You can initialize a unique object (no reference count) with
  bt_object_init_unique(), a shared object that will _never_ have any
  parent with bt_object_init_shared(), and a shared object which could
  have a parent in the future with bt_object_init_shared_with_parent().

  bt_object_init_shared_with_parent() calls bt_object_init_shared() with
  the special `bt_object_with_parent_release_func` callback as the
  object's release function. This function used to be called
  generic_release(): it puts the parent if there is one, or releases the
  object itself (with bt_object_try_spec_release()) when there's none.

  The whole job of bt_object_with_parent_release_func() is unnecessary
  for shared objects which will never have a parent: in this case, we
  can call a single release function as soon as the object's reference
  count falls to zero. This can render the whole system faster as
  notification objects are shared, but without a parent, for example.
  Packet objects are another example, albeit less significant.

* There are two new, internal versions of bt_get() and bt_put() which do
  not check if the parameter is null: bt_object_get_no_null_check() and
  bt_object_put_no_null_check(). We can use those functions internally
  on the fast path where it is known that a given Babeltrace object
  pointer is never null. This is what the public bt_get() and bt_put()
  function use internally now, after checking some preconditions.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
42 files changed:
cli/babeltrace-cfg-cli-args.c
include/Makefile.am
include/babeltrace/ctf-ir/event-class-internal.h
include/babeltrace/ctf-ir/event-internal.h
include/babeltrace/ctf-ir/fields-internal.h
include/babeltrace/ctf-ir/stream-class-internal.h
include/babeltrace/graph/notification-internal.h
include/babeltrace/graph/notification-iterator-internal.h
include/babeltrace/object-internal.h
include/babeltrace/object-pool-internal.h
include/babeltrace/plugin/plugin-internal.h
include/babeltrace/ref-internal.h [deleted file]
lib/ctf-ir/clock-class.c
lib/ctf-ir/event-class.c
lib/ctf-ir/event.c
lib/ctf-ir/field-path.c
lib/ctf-ir/field-types.c
lib/ctf-ir/field-wrapper.c
lib/ctf-ir/fields.c
lib/ctf-ir/packet.c
lib/ctf-ir/stream-class.c
lib/ctf-ir/stream.c
lib/ctf-ir/trace.c
lib/ctf-writer/clock.c
lib/ctf-writer/event.c
lib/ctf-writer/fields.c
lib/ctf-writer/stream.c
lib/ctf-writer/writer.c
lib/graph/clock-class-priority-map.c
lib/graph/component-class.c
lib/graph/component.c
lib/graph/connection.c
lib/graph/graph.c
lib/graph/iterator.c
lib/graph/notification/notification.c
lib/graph/port.c
lib/graph/query-executor.c
lib/lib-logging.c
lib/plugin/plugin-so.c
lib/ref.c
lib/values.c
tests/lib/test_ctf_ir_ref.c
This page took 0.035964 seconds and 4 git commands to generate.