e8819812e139aa28062f86dfb9202241cc81f8b5
[lttng-tools.git] / src / bin / lttng-sessiond / ust-registry-channel.hpp
1 /*
2 * Copyright (C) 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8 #ifndef LTTNG_UST_REGISTRY_CHANNEL_H
9 #define LTTNG_UST_REGISTRY_CHANNEL_H
10
11 #include "stream-class.hpp"
12
13 #include <common/hashtable/hashtable.hpp>
14
15 #include <lttng/lttng.h>
16
17 #include <urcu.h>
18 #include <functional>
19
20 struct ust_app;
21
22 namespace lttng {
23 namespace sessiond {
24 namespace ust {
25
26 class registry_event;
27
28 class registry_channel : public lttng::sessiond::trace::stream_class {
29 public:
30 using registered_listener_fn = std::function<void(const registry_channel&)>;
31 using event_added_listener_fn = std::function<void(const registry_channel&, const registry_event &)>;
32
33 registry_channel(uint32_t channel_id,
34 registered_listener_fn channel_registered_listener,
35 event_added_listener_fn new_event_listener);
36 void add_event(int session_objd,
37 int channel_objd,
38 std::string name,
39 std::string signature,
40 std::vector<lttng::sessiond::trace::field::cuptr> event_fields,
41 int loglevel_value,
42 nonstd::optional<std::string> model_emf_uri,
43 lttng_buffer_type buffer_type,
44 const ust_app& app,
45 uint32_t& out_event_id);
46 virtual ~registry_channel();
47
48 virtual const lttng::sessiond::trace::type& get_context() const override final;
49 void set_context(lttng::sessiond::trace::type::cuptr context);
50
51 /* Channel was registered to at least one application. */
52 bool is_registered() const;
53 void set_as_registered();
54
55 uint64_t _key;
56 uint64_t _consumer_key;
57
58 /*
59 * Flag for this channel if the metadata was dumped once during
60 * registration. 0 means no, 1 yes.
61 */
62 unsigned int _metadata_dumped;
63
64 /*
65 * Hash table containing events sent by the UST tracer. MUST be accessed
66 * with a RCU read side lock acquired.
67 */
68 struct lttng_ht *_events;
69 struct lttng_ht_node_u64 _node;
70 /* For delayed reclaim */
71 struct rcu_head _rcu_head;
72 /* Once this value reaches UINT32_MAX, no more id can be allocated. */
73 uint32_t _next_event_id;
74
75 private:
76 virtual void _accept_on_event_classes(
77 lttng::sessiond::trace::trace_class_visitor& trace_class_visitor) const override final;
78
79 registered_listener_fn _is_registered_listener;
80 event_added_listener_fn _event_added_listener;
81 /* Indicates if this channel registry has already been registered. */
82 bool _is_registered;
83 };
84
85 } /* namespace ust */
86 } /* namespace sessiond */
87 } /* namespace lttng */
88
89 #endif /* LTTNG_UST_REGISTRY_CHANNEL_H */
This page took 0.031053 seconds and 4 git commands to generate.