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);
#ifdef __cplusplus
}
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;
}
-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_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)
GPtrArray *interrupters;
/*
- * Default interrupter to support bt_graph_interrupt(); owned
- * by this.
+ * Default interrupter, owned by this.
*/
struct bt_interrupter *default_interrupter;
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 _user_consume(self):
# Pretend that somebody asynchronously interrupted the graph.
nonlocal graph
- graph.interrupt()
+ graph.default_interrupter.set()
return next(self._msg_iter)
def _user_graph_is_configured(self):