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)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 2 May 2019 20:50:15 +0000 (20:50 +0000)
commitad5268b5815118fd5f01551b43e493214528f88d
treeeefaa6811d55d3a21741c0006474111894ce66d1
parent9dcfa80fb5ee14044c6778d0cb03c38591eb1f3d
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.02593 seconds and 4 git commands to generate.