Fix: do not repurpose iterator while it is being used
[lttng-tools.git] / src / bin / lttng-sessiond / thread.h
CommitLineData
b878f05a
JG
1/*
2 * Copyright (C) 2018 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License, version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18#include <stdbool.h>
19
20#ifndef THREAD_H
21#define THREAD_H
22
23struct lttng_thread;
24
25/* Main function of the new thread. */
26typedef void *(*lttng_thread_entry_point)(void *);
27
28/* Callback invoked to initiate the shutdown a thread. */
29typedef bool (*lttng_thread_shutdown_cb)(void *);
30
31/*
32 * Callback invoked to clean-up the thread data.
33 * Invoked when the thread is destroyed to ensure there is no
34 * race between a use by the "thread shutdown callback" and
35 * a use by the thread itself.
36 */
37typedef void (*lttng_thread_cleanup_cb)(void *);
38
39/*
40 * Returns a reference to the newly-created thread.
41 * The shutdown and cleanup callbacks are optional.
42 */
43struct lttng_thread *lttng_thread_create(const char *name,
44 lttng_thread_entry_point entry,
45 lttng_thread_shutdown_cb shutdown,
46 lttng_thread_cleanup_cb cleanup,
47 void *thread_data);
48
49bool lttng_thread_get(struct lttng_thread *thread);
50void lttng_thread_put(struct lttng_thread *thread);
51
52const char *lttng_thread_get_name(const struct lttng_thread *thread);
53
54/*
55 * Explicitly shutdown a thread. This function returns once the
56 * thread has returned and been joined.
57 *
58 * It is invalid to call this function more than once on a thread.
59 *
60 * Returns true on success, false on error.
61 */
62bool lttng_thread_shutdown(struct lttng_thread *thread);
63
64/*
65 * Shutdown all orphaned threads (threads to which no external reference
66 * exist).
67 *
68 * Returns once all orphaned threads have been joined.
69 */
70void lttng_thread_list_shutdown_orphans(void);
71
72#endif /* THREAD_H */
This page took 0.026753 seconds and 5 git commands to generate.