From e7fa96c3b54878bd96a828be1cc945abfbfc1c64 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Mon, 3 Apr 2017 19:41:35 -0400 Subject: [PATCH] Add frozen property to notification objects MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit A frozen notification cannot be modified (except for its reference count). Currently, no notification can be modified after its creation anyway, but we're excepting some. The notification is frozen by bt_notification_iterator_next() when the component's "next" method is successful. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- include/babeltrace/graph/notification-internal.h | 8 ++++++++ include/babeltrace/graph/notification.h | 2 ++ lib/component/iterator.c | 2 ++ 3 files changed, 12 insertions(+) diff --git a/include/babeltrace/graph/notification-internal.h b/include/babeltrace/graph/notification-internal.h index c5a542d7..01eb5967 100644 --- a/include/babeltrace/graph/notification-internal.h +++ b/include/babeltrace/graph/notification-internal.h @@ -27,6 +27,7 @@ * SOFTWARE. */ +#include #include #include #include @@ -44,6 +45,7 @@ struct bt_notification { struct bt_object base; enum bt_notification_type type; get_stream_func get_stream; + bool frozen; }; BT_HIDDEN @@ -51,6 +53,12 @@ void bt_notification_init(struct bt_notification *notification, enum bt_notification_type type, bt_object_release_func release); +BT_HIDDEN +static inline void bt_notification_freeze(struct bt_notification *notification) +{ + notification->frozen = true; +} + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/notification.h b/include/babeltrace/graph/notification.h index d1797337..c768baae 100644 --- a/include/babeltrace/graph/notification.h +++ b/include/babeltrace/graph/notification.h @@ -69,6 +69,8 @@ enum bt_notification_type { /** End of trace notification, see eot.h */ BT_NOTIFICATION_TYPE_END_OF_TRACE = 8, + BT_NOTIFICATION_TYPE_INACTIVITY = 9, + BT_NOTIFICATION_TYPE_NR, /* Not part of ABI. */ }; diff --git a/lib/component/iterator.c b/lib/component/iterator.c index 5e70e719..ab2783d5 100644 --- a/lib/component/iterator.c +++ b/lib/component/iterator.c @@ -33,6 +33,7 @@ #include #include #include +#include static void bt_notification_iterator_destroy(struct bt_object *obj) @@ -226,6 +227,7 @@ bt_notification_iterator_next(struct bt_notification_iterator *iterator) BT_MOVE(iterator->current_notification, next_return.notification); + bt_notification_freeze(iterator->current_notification); } end: -- 2.34.1