Freeze bt_clock_class_priority_map in related notifications
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 26 Apr 2017 00:40:59 +0000 (20:40 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:41 +0000 (12:57 -0400)
We don't want the relative priorities of a notification's clock classes
(event, inactivity) to change once it's emitted.

Should a new clock class be needed (with its own priority), you should
create a new clock class priority map.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/graph/clock-class-priority-map-internal.h
include/babeltrace/graph/clock-class-priority-map.h
lib/graph/clock-class-priority-map.c
lib/graph/notification/event.c
lib/graph/notification/inactivity.c

index 57c6c86a84699619fc696e7ea2a96756c4424ea9..3cba2bb9ce2b84bc68f7686f1d2cc45f11ab2942 100644 (file)
@@ -28,6 +28,8 @@
 
 #include <stdint.h>
 #include <stddef.h>
+#include <stdbool.h>
+#include <assert.h>
 #include <babeltrace/ctf-ir/clock-class.h>
 #include <babeltrace/object-internal.h>
 #include <glib.h>
@@ -43,6 +45,16 @@ struct bt_clock_class_priority_map {
 
        /* Clock class (weak) with the currently highest priority */
        struct bt_ctf_clock_class *highest_prio_cc;
+
+       bool frozen;
 };
 
+static inline
+void bt_clock_class_priority_map_freeze(
+               struct bt_clock_class_priority_map *cc_prio_map)
+{
+       assert(cc_prio_map);
+       cc_prio_map->frozen = true;
+}
+
 #endif /* BABELTRACE_GRAPH_CLOCK_CLASS_PRIORITY_MAP_INTERNAL_H */
index 18c27308086e05f09bf7a2486b28e20a9671dfe1..575e31c176c74848601227ba2460c92deb7308fd 100644 (file)
@@ -56,6 +56,16 @@ A priority is a 64-bit unsigned integer. A lower value has a
 \em higher priority. Multiple clock classes can have the same priority
 within a given clock class priority map.
 
+The following functions can \em freeze clock class priority map objects:
+
+- bt_notification_event_create() freezes its clock class priority
+  map parameter.
+- bt_notification_inactivity_create() freezes its clock class priority
+  map parameter.
+
+You cannot modify a frozen clock class priority map object: it is
+considered immutable, except for \link refs reference counting\endlink.
+
 As with any Babeltrace object, clock class priority map objects have
 <a href="https://en.wikipedia.org/wiki/Reference_counting">reference
 counts</a>. See \ref refs to learn more about the reference counting
@@ -256,6 +266,7 @@ map.
 
 @prenotnull{clock_class_priority_map}
 @prenotnull{clock_class}
+@prehot{clock_class_priority_map}
 @postrefcountsame{clock_class_priority_map}
 @postsuccessrefcountinc{clock_class}
 
index f9055198ab0249b86a1fa3c7ef5432e0f08a8a78..136ed276de4a11c1ff8532948634a34fa3715d80 100644 (file)
@@ -229,7 +229,7 @@ int bt_clock_class_priority_map_add_clock_class(
 
        // FIXME when available: check
        // bt_ctf_clock_class_is_valid(clock_class)
-       if (!cc_prio_map) {
+       if (!cc_prio_map || !clock_class || cc_prio_map->frozen) {
                ret = -1;
                goto end;
        }
index 6a1903dc34998d959b0f8623466e4a26c7f861ab..44bb6f23c73215361692066990d8b40d4740def9 100644 (file)
@@ -31,6 +31,7 @@
 #include <babeltrace/ctf-ir/stream-class-internal.h>
 #include <babeltrace/ctf-ir/trace.h>
 #include <babeltrace/graph/clock-class-priority-map.h>
+#include <babeltrace/graph/clock-class-priority-map-internal.h>
 #include <babeltrace/graph/notification-event-internal.h>
 
 static
@@ -144,6 +145,7 @@ struct bt_notification *bt_notification_event_create(struct bt_ctf_event *event,
        }
 
        bt_ctf_event_freeze(notification->event);
+       bt_clock_class_priority_map_freeze(notification->cc_prio_map);
        return &notification->parent;
 error:
        bt_put(notification);
index 48073955ee303a443549063340205c637bf1f937..27b6916f689f798bc8f765d320b4163bf58748da 100644 (file)
@@ -24,6 +24,7 @@
 #include <babeltrace/compiler-internal.h>
 #include <babeltrace/ctf-ir/clock-class.h>
 #include <babeltrace/graph/clock-class-priority-map.h>
+#include <babeltrace/graph/clock-class-priority-map-internal.h>
 #include <babeltrace/graph/notification-internal.h>
 #include <babeltrace/graph/notification-inactivity-internal.h>
 
@@ -67,6 +68,7 @@ struct bt_notification *bt_notification_inactivity_create(
        }
 
        notification->cc_prio_map = bt_get(cc_prio_map);
+       bt_clock_class_priority_map_freeze(cc_prio_map);
        goto end;
 
 error:
This page took 0.026943 seconds and 4 git commands to generate.