trackers: add sessiond tracker list implementation
[lttng-tools.git] / src / bin / lttng-sessiond / tracker.h
1 #ifndef _LTT_TRACKER_H
2 #define _LTT_TRACKER_H
3
4 /*
5 * Copyright (C) 2018 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License, version 2 only,
9 * as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #include <lttng/session.h>
22 #include <urcu.h>
23 #include <urcu/list.h>
24 #include <urcu/rculfhash.h>
25
26 enum lttng_tracker_list_state {
27 LTTNG_TRACK_ALL,
28 LTTNG_TRACK_NONE,
29 LTTNG_TRACK_LIST,
30 };
31
32 /* Tracker ID */
33 struct lttng_tracker_list_node {
34 struct lttng_tracker_id id;
35
36 struct cds_list_head list_node;
37 struct cds_lfht_node ht_node;
38 struct rcu_head rcu_head;
39 };
40
41 struct lttng_tracker_list {
42 struct cds_list_head list_head;
43 /* Hash table for O(1) removal lookup. */
44 struct cds_lfht *ht;
45 enum lttng_tracker_list_state state;
46 };
47
48 struct lttng_tracker_list *lttng_tracker_list_create(void);
49 void lttng_tracker_list_destroy(struct lttng_tracker_list *tracker_list);
50
51 int lttng_tracker_list_add(struct lttng_tracker_list *tracker_list,
52 const struct lttng_tracker_id *id);
53 int lttng_tracker_list_remove(struct lttng_tracker_list *tracker_list,
54 const struct lttng_tracker_id *id);
55
56 int lttng_tracker_id_lookup_string(enum lttng_tracker_type tracker_type,
57 const struct lttng_tracker_id *id,
58 int *result);
59 ssize_t lttng_tracker_id_get_list(const struct lttng_tracker_list *tracker_list,
60 struct lttng_tracker_id **_ids);
61 int lttng_tracker_id_set_list(struct lttng_tracker_list *tracker_list,
62 struct lttng_tracker_id *_ids,
63 size_t count);
64
65 #endif /* _LTT_TRACKER_H */
This page took 0.044192 seconds and 5 git commands to generate.