It is currently possible to interrupt a running graph with
bt_graph_interrupt. It is however not possible to reset the default
interrupter that this function sets and resume the graph execution.
Rather than add a new graph function to reset the default graph
interrupter, introduce a new function,
bt_graph_borrow_default_interrupter, to borrow that default interrupter.
All the bt_interrupter API is therefore accessible with this default
interrupter.
This patch removes the bt_graph_interrupt function, since it's no longer
needed.
Change-Id: I277e6c8bb4e1be0a6557a6287b7ba8997e20d27b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2708
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
extern bt_graph_add_interrupter_status bt_graph_add_interrupter(bt_graph *graph,
const bt_interrupter *interrupter);
extern bt_graph_add_interrupter_status bt_graph_add_interrupter(bt_graph *graph,
const bt_interrupter *interrupter);
-extern void bt_graph_interrupt(bt_graph *graph);
+extern bt_interrupter *bt_graph_borrow_default_interrupter(bt_graph *graph);
utils._check_type(interrupter, bt2_interrupter.Interrupter)
native_bt.graph_add_interrupter(self._ptr, interrupter._ptr)
utils._check_type(interrupter, bt2_interrupter.Interrupter)
native_bt.graph_add_interrupter(self._ptr, interrupter._ptr)
- def interrupt(self):
- native_bt.graph_interrupt(self._ptr)
+ @property
+ def default_interrupter(self):
+ ptr = native_bt.graph_borrow_default_interrupter(self._ptr)
+ return bt2_interrupter.Interrupter._create_from_ptr_and_get_ref(ptr)
return BT_FUNC_STATUS_OK;
}
return BT_FUNC_STATUS_OK;
}
-void bt_graph_interrupt(struct bt_graph *graph)
+struct bt_interrupter *bt_graph_borrow_default_interrupter(bt_graph *graph)
{
BT_ASSERT_PRE_NON_NULL(graph, "Graph");
{
BT_ASSERT_PRE_NON_NULL(graph, "Graph");
- bt_interrupter_set(graph->default_interrupter);
- BT_LIB_LOGI("Interrupted graph: %!+g", graph);
+ return graph->default_interrupter;
}
void bt_graph_get_ref(const struct bt_graph *graph)
}
void bt_graph_get_ref(const struct bt_graph *graph)
GPtrArray *interrupters;
/*
GPtrArray *interrupters;
/*
- * Default interrupter to support bt_graph_interrupt(); owned
- * by this.
+ * Default interrupter, owned by this.
*/
struct bt_interrupter *default_interrupter;
*/
struct bt_interrupter *default_interrupter;
with self.assertRaisesRegex(ValueError, 'unknown MIP version'):
bt2.Graph(1)
with self.assertRaisesRegex(ValueError, 'unknown MIP version'):
bt2.Graph(1)
+ def test_default_interrupter(self):
+ interrupter = self._graph.default_interrupter
+ self.assertIs(type(interrupter), bt2.Interrupter)
+
def test_add_component_user_cls(self):
class MySink(bt2._UserSinkComponent):
def _user_consume(self):
def test_add_component_user_cls(self):
class MySink(bt2._UserSinkComponent):
def _user_consume(self):
def _user_consume(self):
# Pretend that somebody asynchronously interrupted the graph.
nonlocal graph
def _user_consume(self):
# Pretend that somebody asynchronously interrupted the graph.
nonlocal graph
+ graph.default_interrupter.set()
return next(self._msg_iter)
def _user_graph_is_configured(self):
return next(self._msg_iter)
def _user_graph_is_configured(self):