Babeltrace 2 C API
2.0.0
Open-source trace manipulation framework
|
Interrupter.
An interrupter is a simple object which has a single boolean state: set or not set.
You can use an interrupter to interrupt a running trace processing graph or query. The user and library functions periodically check if they are interrupted (with bt_self_component_sink_is_interrupted(), bt_self_message_iterator_is_interrupted(), or bt_query_executor_is_interrupted()); meanwhile, another thread or a signal handler sets the shared interrupter with bt_interrupter_set().
To interrupt a running trace processing graph or query:
Before running a trace processing graph with bt_graph_run() or performing a query with bt_query_executor_query(), add the created interrupter to the object with bt_graph_add_interrupter() or bt_query_executor_add_interrupter().
Alternatively, you can borrow the existing, default interrupter from those objects with bt_graph_borrow_default_interrupter() and bt_query_executor_borrow_default_interrupter().
Eventually, the trace processing graph or query thread checks if it's interrupted and stops processing, usually returning a status code which ends with _AGAIN
.
You can add more than one interrupter to a trace processing graph and to a query executor. The bt_self_component_sink_is_interrupted(), bt_self_message_iterator_is_interrupted(), and bt_query_executor_is_interrupted() functions return the logical disjunction of all the added interrupters's states, so that any interrupter can interrupt the thread.
Once a trace processing graph or a query executor is interrupted and you get the thread's control back, you can reset the interrupter with bt_interrupter_reset() and continue the previous operation, calling bt_graph_run() or bt_query_executor_query() again.
An interrupter is a shared object: get a new reference with bt_interrupter_get_ref() and put an existing reference with bt_interrupter_put_ref().
The type of an interrupter is bt_interrupter.
Type | |
typedef struct bt_interrupter | bt_interrupter |
Interrupter. | |
Creation | |
bt_interrupter * | bt_interrupter_create (void) |
Creates a default interrupter. More... | |
State | |
void | bt_interrupter_set (bt_interrupter *interrupter) |
Sets the interrupter interrupter. More... | |
void | bt_interrupter_reset (bt_interrupter *interrupter) |
Resets the interrupter interrupter. More... | |
bt_bool | bt_interrupter_is_set (const bt_interrupter *interrupter) |
Returns whether or not the interrupter interrupter is set. More... | |
Reference count | |
void | bt_interrupter_get_ref (const bt_interrupter *interrupter) |
Increments the reference count of the interrupter interrupter. More... | |
void | bt_interrupter_put_ref (const bt_interrupter *interrupter) |
Decrements the reference count of the interrupter interrupter. More... | |
#define | BT_INTERRUPTER_PUT_REF_AND_RESET(_interrupter) |
Decrements the reference count of the interrupter _interrupter, and then sets _interrupter to NULL . More... | |
#define | BT_INTERRUPTER_MOVE_REF(_dst, _src) |
Decrements the reference count of the interrupter _dst, sets _dst to _src, and then sets _src to NULL . More... | |
#define BT_INTERRUPTER_PUT_REF_AND_RESET | ( | _interrupter | ) |
Decrements the reference count of the interrupter _interrupter, and then sets _interrupter to NULL
.
_interrupter | Interrupter of which to decrement the reference count. Can contain |
#define BT_INTERRUPTER_MOVE_REF | ( | _dst, | |
_src | |||
) |
Decrements the reference count of the interrupter _dst, sets _dst to _src, and then sets _src to NULL
.
This macro effectively moves an interrupter reference from the expression _src to the expression _dst, putting the existing _dst reference.
_dst | Destination expression. Can contain |
_src | Source expression. Can contain |
bt_interrupter* bt_interrupter_create | ( | void | ) |
Creates a default interrupter.
On success, the returned interrupter is not set (bt_interrupter_is_set() returns BT_FALSE).
NULL
on memory error. void bt_interrupter_set | ( | bt_interrupter * | interrupter | ) |
Sets the interrupter interrupter.
After you call this function, bt_interrupter_is_set() returns BT_TRUE.
[in] | interrupter | Interrupter to set. |
NULL
.void bt_interrupter_reset | ( | bt_interrupter * | interrupter | ) |
Resets the interrupter interrupter.
After you call this function, bt_interrupter_is_set() returns BT_FALSE.
[in] | interrupter | Interrupter to reset. |
NULL
.bt_bool bt_interrupter_is_set | ( | const bt_interrupter * | interrupter | ) |
Returns whether or not the interrupter interrupter is set.
[in] | interrupter | Interrupter to reset. |
NULL
.void bt_interrupter_get_ref | ( | const bt_interrupter * | interrupter | ) |
Increments the reference count of the interrupter interrupter.
[in] | interrupter | Interrupter of which to increment the reference count. Can be |
void bt_interrupter_put_ref | ( | const bt_interrupter * | interrupter | ) |
Decrements the reference count of the interrupter interrupter.
[in] | interrupter | Interrupter of which to decrement the reference count. Can be |