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)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 May 2019 22:19:38 +0000 (18:19 -0400)
commit2d2affbb734a033115294b6f990edea6dff4ae67
tree602c1f43630ebe996a852acb31da6e320db876d2
parentc9d3ff42c006dbbbb746f4192eb5d2fa1c110067
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.026955 seconds and 4 git commands to generate.