Visibility hidden by default
[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 <stdlib.h>
11 #include <stdint.h>
12 #include <babeltrace2/babeltrace.h>
13
14 #include "interrupter.h"
15 #include "lib/assert-cond.h"
16
17 static
18 void destroy_interrupter(struct bt_object *obj)
19 {
20 g_free(obj);
21 }
22
23 BT_EXPORT
24 struct bt_interrupter *bt_interrupter_create(void)
25 {
26 struct bt_interrupter *intr = g_new0(struct bt_interrupter, 1);
27
28 BT_ASSERT_PRE_NO_ERROR();
29
30 if (!intr) {
31 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one interrupter.");
32 goto error;
33 }
34
35 bt_object_init_shared(&intr->base, destroy_interrupter);
36 goto end;
37
38 error:
39 BT_OBJECT_PUT_REF_AND_RESET(intr);
40
41 end:
42 return intr;
43 }
44
45 BT_EXPORT
46 void bt_interrupter_set(struct bt_interrupter *intr)
47 {
48 BT_ASSERT_PRE_INTR_NON_NULL(intr);
49 intr->is_set = true;
50 }
51
52 BT_EXPORT
53 void bt_interrupter_reset(struct bt_interrupter *intr)
54 {
55 BT_ASSERT_PRE_INTR_NON_NULL(intr);
56 intr->is_set = false;
57 }
58
59 BT_EXPORT
60 bt_bool bt_interrupter_is_set(const struct bt_interrupter *intr)
61 {
62 BT_ASSERT_PRE_INTR_NON_NULL(intr);
63 return (bt_bool) intr->is_set;
64 }
65
66 BT_EXPORT
67 void bt_interrupter_get_ref(const struct bt_interrupter *intr)
68 {
69 bt_object_get_ref(intr);
70 }
71
72 BT_EXPORT
73 void bt_interrupter_put_ref(const struct bt_interrupter *intr)
74 {
75 bt_object_put_ref(intr);
76 }
This page took 0.030586 seconds and 4 git commands to generate.