| 1 | /* |
| 2 | * SPDX-License-Identifier: MIT |
| 3 | * |
| 4 | * Copyright (c) 2019 Philippe Proulx <pproulx@efficios.com> |
| 5 | */ |
| 6 | |
| 7 | #ifndef BABELTRACE_LIB_GRAPH_INTERRUPTER_H |
| 8 | #define BABELTRACE_LIB_GRAPH_INTERRUPTER_H |
| 9 | |
| 10 | #include <stdbool.h> |
| 11 | |
| 12 | #include <glib.h> |
| 13 | #include <babeltrace2/babeltrace.h> |
| 14 | |
| 15 | #include "lib/object.h" |
| 16 | |
| 17 | struct bt_interrupter { |
| 18 | struct bt_object base; |
| 19 | bool is_set; |
| 20 | }; |
| 21 | |
| 22 | static inline |
| 23 | bool bt_interrupter_array_any_is_set(const GPtrArray *interrupters) |
| 24 | { |
| 25 | bool is_set = false; |
| 26 | uint64_t i; |
| 27 | |
| 28 | BT_ASSERT_DBG(interrupters); |
| 29 | |
| 30 | for (i = 0; i < interrupters->len; i++) { |
| 31 | const struct bt_interrupter *intr = interrupters->pdata[i]; |
| 32 | |
| 33 | if (intr->is_set) { |
| 34 | is_set = true; |
| 35 | goto end; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | end: |
| 40 | return is_set; |
| 41 | } |
| 42 | |
| 43 | #endif /* BABELTRACE_LIB_GRAPH_INTERRUPTER_H */ |