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>
This page took 0.026328 seconds and 4 git commands to generate.