2 * Copyright (C) 2018 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
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.
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
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.
25 /* Main function of the new thread. */
26 typedef void *(*lttng_thread_entry_point
)(void *);
28 /* Callback invoked to initiate the shutdown a thread. */
29 typedef bool (*lttng_thread_shutdown_cb
)(void *);
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.
37 typedef void (*lttng_thread_cleanup_cb
)(void *);
40 * Returns a reference to the newly-created thread.
41 * The shutdown and cleanup callbacks are optional.
43 struct 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
,
49 bool lttng_thread_get(struct lttng_thread
*thread
);
50 void lttng_thread_put(struct lttng_thread
*thread
);
52 const char *lttng_thread_get_name(const struct lttng_thread
*thread
);
55 * Explicitly shutdown a thread. This function returns once the
56 * thread has returned and been joined.
58 * It is invalid to call this function more than once on a thread.
60 * Returns true on success, false on error.
62 bool lttng_thread_shutdown(struct lttng_thread
*thread
);
65 * Shutdown all orphaned threads (threads to which no external reference
68 * Returns once all orphaned threads have been joined.
70 void lttng_thread_list_shutdown_orphans(void);