Move to kernel style SPDX license identifiers
[babeltrace.git] / src / lib / graph / interrupter.c
CommitLineData
b70d57a1 1/*
0235b0db 2 * SPDX-License-Identifier: MIT
b70d57a1 3 *
0235b0db 4 * Copyright (c) 2019 Philippe Proulx <pproulx@efficios.com>
b70d57a1
PP
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-pre.h"
16
17static
18void destroy_interrupter(struct bt_object *obj)
19{
20 g_free(obj);
21}
22
23extern struct bt_interrupter *bt_interrupter_create(void)
24{
25 struct bt_interrupter *intr = g_new0(struct bt_interrupter, 1);
26
17f3083a
SM
27 BT_ASSERT_PRE_NO_ERROR();
28
b70d57a1
PP
29 if (!intr) {
30 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one interrupter.");
31 goto error;
32 }
33
34 bt_object_init_shared(&intr->base, destroy_interrupter);
35 goto end;
36
37error:
38 BT_OBJECT_PUT_REF_AND_RESET(intr);
39
40end:
41 return intr;
42}
43
44void bt_interrupter_set(struct bt_interrupter *intr)
45{
46 BT_ASSERT_PRE_NON_NULL(intr, "Interrupter");
47 intr->is_set = true;
48}
49
50void bt_interrupter_reset(struct bt_interrupter *intr)
51{
52 BT_ASSERT_PRE_NON_NULL(intr, "Interrupter");
53 intr->is_set = false;
54}
55
56bt_bool bt_interrupter_is_set(const struct bt_interrupter *intr)
57{
58 BT_ASSERT_PRE_NON_NULL(intr, "Interrupter");
59 return (bt_bool) intr->is_set;
60}
61
62void bt_interrupter_get_ref(const struct bt_interrupter *intr)
63{
64 bt_object_get_ref(intr);
65}
66
67void bt_interrupter_put_ref(const struct bt_interrupter *intr)
68{
69 bt_object_put_ref(intr);
70}
This page took 0.041566 seconds and 4 git commands to generate.