cpp-common/bt2c/fmt.hpp: use `wise_enum::string_type` in `EnableIfIsWiseEnum` definition
[babeltrace.git] / src / lib / graph / interrupter.c
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (c) 2019 Philippe Proulx <pproulx@efficios.com>
5 */
6
7 #define BT_LOG_TAG "LIB/INTERRUPTER"
8 #include "lib/logging.h"
9
10 #include <babeltrace2/babeltrace.h>
11
12 #include "interrupter.h"
13 #include "lib/assert-cond.h"
14
15 static
16 void destroy_interrupter(struct bt_object *obj)
17 {
18 g_free(obj);
19 }
20
21 BT_EXPORT
22 struct bt_interrupter *bt_interrupter_create(void)
23 {
24 struct bt_interrupter *intr = g_new0(struct bt_interrupter, 1);
25
26 BT_ASSERT_PRE_NO_ERROR();
27
28 if (!intr) {
29 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one interrupter.");
30 goto error;
31 }
32
33 bt_object_init_shared(&intr->base, destroy_interrupter);
34 goto end;
35
36 error:
37 BT_OBJECT_PUT_REF_AND_RESET(intr);
38
39 end:
40 return intr;
41 }
42
43 BT_EXPORT
44 void bt_interrupter_set(struct bt_interrupter *intr)
45 {
46 BT_ASSERT_PRE_INTR_NON_NULL(intr);
47 intr->is_set = true;
48 }
49
50 BT_EXPORT
51 void bt_interrupter_reset(struct bt_interrupter *intr)
52 {
53 BT_ASSERT_PRE_INTR_NON_NULL(intr);
54 intr->is_set = false;
55 }
56
57 BT_EXPORT
58 bt_bool bt_interrupter_is_set(const struct bt_interrupter *intr)
59 {
60 BT_ASSERT_PRE_INTR_NON_NULL(intr);
61 return (bt_bool) intr->is_set;
62 }
63
64 BT_EXPORT
65 void bt_interrupter_get_ref(const struct bt_interrupter *intr)
66 {
67 bt_object_get_ref(intr);
68 }
69
70 BT_EXPORT
71 void bt_interrupter_put_ref(const struct bt_interrupter *intr)
72 {
73 bt_object_put_ref(intr);
74 }
This page took 0.029855 seconds and 4 git commands to generate.