lib: update and simplify the `bt_object` API
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 12 Jun 2018 19:47:05 +0000 (15:47 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 May 2019 22:19:34 +0000 (18:19 -0400)
commit1d7bf34933f21be1aac814b60dc0def7d4506c89
treefdbf7775c6bdd741c13ed513f624768284714608
parent164e96c28978ce0c2fdd64779e9e2e9fc8aaaf81
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.032162 seconds and 4 git commands to generate.