2 * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
15 /* Main function of the new thread. */
16 typedef void *(*lttng_thread_entry_point
)(void *);
18 /* Callback invoked to initiate the shutdown a thread. */
19 typedef bool (*lttng_thread_shutdown_cb
)(void *);
22 * Callback invoked to clean-up the thread data.
23 * Invoked when the thread is destroyed to ensure there is no
24 * race between a use by the "thread shutdown callback" and
25 * a use by the thread itself.
27 typedef void (*lttng_thread_cleanup_cb
)(void *);
30 * Returns a reference to the newly-created thread.
31 * The shutdown and cleanup callbacks are optional.
33 struct lttng_thread
*lttng_thread_create(const char *name
,
34 lttng_thread_entry_point entry
,
35 lttng_thread_shutdown_cb shutdown
,
36 lttng_thread_cleanup_cb cleanup
,
39 bool lttng_thread_get(struct lttng_thread
*thread
);
40 void lttng_thread_put(struct lttng_thread
*thread
);
42 const char *lttng_thread_get_name(const struct lttng_thread
*thread
);
45 * Explicitly shutdown a thread. This function returns once the
46 * thread has returned and been joined.
48 * It is invalid to call this function more than once on a thread.
50 * Returns true on success, false on error.
52 bool lttng_thread_shutdown(struct lttng_thread
*thread
);
55 * Shutdown all orphaned threads (threads to which no external reference
58 * Returns once all orphaned threads have been joined.
60 void lttng_thread_list_shutdown_orphans(void);