Cleanup: rotation-thread: enforce conding standard following fix
[lttng-tools.git] / src / bin / lttng-sessiond / rotation-thread.hpp
1 /*
2 * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
3 * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 */
8
9 #ifndef ROTATION_THREAD_H
10 #define ROTATION_THREAD_H
11
12 #include "notification-thread.hpp"
13 #include "session.hpp"
14
15 #include <common/compat/poll.hpp>
16 #include <common/eventfd.hpp>
17 #include <common/hashtable/hashtable.hpp>
18 #include <common/make-unique-wrapper.hpp>
19 #include <common/pipe.hpp>
20
21 #include <lttng/domain.h>
22 #include <lttng/notification/channel-internal.hpp>
23
24 #include <memory>
25 #include <pthread.h>
26 #include <semaphore.h>
27 #include <urcu.h>
28 #include <urcu/list.h>
29 #include <urcu/rculfhash.h>
30
31 namespace lttng {
32 namespace sessiond {
33
34 enum class rotation_thread_job_type {
35 SCHEDULED_ROTATION,
36 CHECK_PENDING_ROTATION
37 };
38
39 struct rotation_thread_timer_queue;
40
41 class rotation_thread {
42 public:
43 using uptr = std::unique_ptr<rotation_thread>;
44
45 rotation_thread(rotation_thread_timer_queue& rotation_timer_queue,
46 notification_thread_handle& notification_thread_handle);
47 ~rotation_thread();
48
49 /* Only use through the lttng_thread facilities. */
50 void launch_thread();
51 bool shutdown() const noexcept;
52
53 /*
54 * Subscribe/unsubscribe the rotation_thread's notification_channel to/from
55 * session usage notifications to perform size-based rotations.
56 */
57 void subscribe_session_consumed_size_rotation(ltt_session& session, std::uint64_t size);
58 void unsubscribe_session_consumed_size_rotation(ltt_session& session);
59
60 private:
61 void _thread_function() noexcept;
62 void _run();
63 void _handle_job_queue();
64 void _handle_notification(const lttng_notification& notification);
65 void _handle_notification_channel_activity();
66
67 struct rotation_thread_timer_queue& _rotation_timer_queue;
68 /* Access to the notification thread cmd_queue */
69 notification_thread_handle& _notification_thread_handle;
70 /* Thread-specific quit pipe. */
71 lttng_pipe::uptr _quit_pipe;
72 lttng_notification_channel::uptr _notification_channel;
73 /*
74 * Use an event_fd to wake-up the rotation thread whenever a command
75 * completes on the notification channel. This ensures that any
76 * notification that was queued while waiting for a reply to the command is
77 * eventually consumed.
78 */
79 lttng::eventfd _notification_channel_subscribtion_change_eventfd;
80 lttng_poll_event _events;
81 };
82
83 struct rotation_thread_timer_queue *rotation_thread_timer_queue_create(void);
84 void rotation_thread_timer_queue_destroy(struct rotation_thread_timer_queue *queue);
85 void rotation_thread_enqueue_job(struct rotation_thread_timer_queue *queue,
86 enum rotation_thread_job_type job_type,
87 struct ltt_session *session);
88
89 } /* namespace sessiond */
90 } /* namespace lttng */
91
92 #endif /* ROTATION_THREAD_H */
This page took 0.032623 seconds and 5 git commands to generate.