lib: replace trace is_static with destruction listeners
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Tue, 26 Feb 2019 23:45:02 +0000 (18:45 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 May 2019 22:19:38 +0000 (18:19 -0400)
commit1122415c8d0e87cdf3c844bb20c2159d10eb13a3
tree6944d78babb5d6473096a5c7a56d9bdca279010d
parent591cf554d29a63baf57c869251a7ef09f944ae0c
lib: replace trace is_static with destruction listeners

General idea
------------
Replace bt_trace is_static infrastructure with the concept of
destruction listener and extend it for the bt_trace_class object.

This allows for downstream components to ask to be notify of the
destruction of those objects. This notification is useful for component
that keep data related trace IR objects that should be deallocated when
the trace and/or trace class are destroyed.

This feature is mostly useful to handle sources which could create and
release lots of trace class and trace objects. In this case, when the
source message iterator is done with the stream objects (emitted all the
relevant stream end messages), it puts the stream, trace, and trace
class references. Then downstream users are notified that specific
external objects are about to be destroyed, so they release/close any
associated resource.

The flt.lttng-utils.debug-info component will make use of this
capability to cleanup the mapping between input and output objects it
needs to manage to do its function.

Implementation
--------------
Both trace class and trace offer the same interface and are implemented
in the exact same way.

Destruction listener callbacks and their associated private pointer are
stored in an array and are all called at the execution of the destroy
functions. Destruction listeners are registered using the following
functions:

  bt_trace_status bt_trace_add_destruction_listener(
          const bt_trace *trace,
          bt_trace_destruction_listener_func listener,
          void *data,
          uint64_t *listener_id);

  bt_trace_class_status bt_trace_class_add_destruction_listener(
          const bt_trace_class *trace,
          bt_trace_class_destruction_listener_func listener,
          void *data,
          uint64_t *listener_id);

It's possible to remove a destruction listener using the destruction
listener id received when register it initially used the following
functions:

  bt_trace_status bt_trace_remove_destruction_listener(
          const bt_trace *trace,
          uint64_t listener_id);

  bt_trace_class_status bt_trace_class_remove_destruction_listener(
          const bt_trace_class *trace_class,
          uint64_t listener_id);

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
include/babeltrace/trace-ir/trace-class-const.h
include/babeltrace/trace-ir/trace-class-internal.h
include/babeltrace/trace-ir/trace-const.h
include/babeltrace/trace-ir/trace-internal.h
include/babeltrace/trace-ir/trace.h
lib/lib-logging.c
lib/trace-ir/stream.c
lib/trace-ir/trace-class.c
lib/trace-ir/trace.c
plugins/ctf/fs-src/fs.c
plugins/text/dmesg/dmesg.c
This page took 0.030569 seconds and 4 git commands to generate.