lib: message API: add fast default clock class accessors
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 19 Feb 2019 18:56:37 +0000 (13:56 -0500)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 2 May 2019 20:50:15 +0000 (20:50 +0000)
commit33931ab8fa9ae0cb4eb9bfdbbc9acc4d7b53ac17
tree71ef472a51ba67486a490ed3ffc57e9e06ea56b6
parentb5443165dea4fc66cabe3173a5d09fa1e8caef9b
lib: message API: add fast default clock class accessors

This patch adds a few
bt_message_X_borrow_stream_class_default_clock_class() functions to
quickly get the default clock class of a message's stream class.

It is a library precondition that a message's stream class has a default
clock class in order to borrow its default clock snapshot. This is
because, sometimes, a default clock snapshot object exists even if it's
never used for pooling and allocation reasons. There's no conditional in
the clock snapshot borrowing functions for performance reasons, so you
can't rely on the clock snapshot output parameter being `NULL` or not.
The correct way to know whether or not there's a default clock snapshot
to check if the message's stream class has a default clock class, which
you can now do in a single call.

For example, before:

    const bt_message *event_msg = ...;
    const bt_event *event = bt_message_event_borrow_event_const(event_msg);
    const bt_packet *packet = bt_event_borrow_packet_const(event);
    const bt_stream *stream = bt_packet_borrow_stream_const(event);
    const bt_stream_class *stream_class =
        bt_stream_borrow_class_const(stream);
    const bt_clock_class *def_clock_class =
        bt_stream_class_borrow_default_clock_class_const(stream_class);

    if (def_clock_class) {
        /* safe to borrow message's default clock snapshot */
    }

Now:

    const bt_message *event_msg = ...;
    const bt_clock_class *def_clock_class =
        bt_message_event_borrow_stream_class_default_clock_class_const(
            event_msg);

    if (def_clock_class) {
        /* safe to borrow message's default clock snapshot */
    }

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
include/babeltrace/graph/message-discarded-events-const.h
include/babeltrace/graph/message-discarded-packets-const.h
include/babeltrace/graph/message-event-const.h
include/babeltrace/graph/message-packet-beginning-const.h
include/babeltrace/graph/message-packet-end-const.h
include/babeltrace/graph/message-stream-activity-beginning-const.h
include/babeltrace/graph/message-stream-activity-end-const.h
lib/graph/message/discarded-items.c
lib/graph/message/event.c
lib/graph/message/packet.c
lib/graph/message/stream-activity.c
This page took 0.02626 seconds and 4 git commands to generate.