1422a6dceed667050da6870928a6d02ecd0d2db2
[lttng-tools.git] / include / lttng / action / action-internal.h
1 /*
2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8 #ifndef LTTNG_ACTION_INTERNAL_H
9 #define LTTNG_ACTION_INTERNAL_H
10
11 #include <lttng/action/action.h>
12 #include <common/macros.h>
13 #include <common/buffer-view.h>
14 #include <common/dynamic-buffer.h>
15 #include <common/payload-view.h>
16 #include <common/payload.h>
17 #include <stdbool.h>
18 #include <sys/types.h>
19 #include <urcu/ref.h>
20
21 struct lttng_firing_policy;
22
23 typedef bool (*action_validate_cb)(struct lttng_action *action);
24 typedef void (*action_destroy_cb)(struct lttng_action *action);
25 typedef int (*action_serialize_cb)(struct lttng_action *action,
26 struct lttng_payload *payload);
27 typedef bool (*action_equal_cb)(const struct lttng_action *a,
28 const struct lttng_action *b);
29 typedef ssize_t (*action_create_from_payload_cb)(
30 struct lttng_payload_view *view,
31 struct lttng_action **action);
32 typedef const struct lttng_firing_policy *(*action_get_firing_policy_cb)(
33 const struct lttng_action *action);
34
35 struct lttng_action {
36 struct urcu_ref ref;
37 enum lttng_action_type type;
38 action_validate_cb validate;
39 action_serialize_cb serialize;
40 action_equal_cb equal;
41 action_destroy_cb destroy;
42 action_get_firing_policy_cb get_firing_policy;
43
44 /* Internal use only. */
45
46 /* The number of time the actions was enqueued for execution. */
47 uint64_t execution_request_counter;
48 /*
49 * The number of time the action was actually executed.
50 * Action firing policy can impact on this number.
51 * */
52 uint64_t execution_counter;
53 /*
54 * The number of time the action execution failed.
55 */
56 uint64_t execution_failure_counter;
57 };
58
59 struct lttng_action_comm {
60 /* enum lttng_action_type */
61 int8_t action_type;
62 } LTTNG_PACKED;
63
64 LTTNG_HIDDEN
65 void lttng_action_init(struct lttng_action *action,
66 enum lttng_action_type type,
67 action_validate_cb validate,
68 action_serialize_cb serialize,
69 action_equal_cb equal,
70 action_destroy_cb destroy,
71 action_get_firing_policy_cb get_firing_policy);
72
73 LTTNG_HIDDEN
74 bool lttng_action_validate(struct lttng_action *action);
75
76 LTTNG_HIDDEN
77 int lttng_action_serialize(struct lttng_action *action,
78 struct lttng_payload *buf);
79
80 LTTNG_HIDDEN
81 ssize_t lttng_action_create_from_payload(struct lttng_payload_view *view,
82 struct lttng_action **action);
83
84 LTTNG_HIDDEN
85 bool lttng_action_is_equal(const struct lttng_action *a,
86 const struct lttng_action *b);
87
88 LTTNG_HIDDEN
89 void lttng_action_get(struct lttng_action *action);
90
91 LTTNG_HIDDEN
92 void lttng_action_put(struct lttng_action *action);
93
94 LTTNG_HIDDEN
95 const char* lttng_action_type_string(enum lttng_action_type action_type);
96
97 LTTNG_HIDDEN
98 void lttng_action_increase_execution_request_count(struct lttng_action *action);
99
100 LTTNG_HIDDEN
101 void lttng_action_increase_execution_count(struct lttng_action *action);
102
103 LTTNG_HIDDEN
104 void lttng_action_increase_execution_failure_count(struct lttng_action *action);
105
106 LTTNG_HIDDEN
107 bool lttng_action_should_execute(const struct lttng_action *action);
108
109 #endif /* LTTNG_ACTION_INTERNAL_H */
This page took 0.030174 seconds and 3 git commands to generate.