X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fthread.cpp;h=661bc517b2f6a37e8ffa29c935d09f1583f73867;hb=28ab034a2c3582d07d3423d2d746731f87d3969f;hp=446a8c9d2e52276dd5972cf869884c57ec22bb78;hpb=7966af5763c4aaca39df9bbfa9277ff15715c720;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/thread.cpp b/src/bin/lttng-sessiond/thread.cpp index 446a8c9d2..661bc517b 100644 --- a/src/bin/lttng-sessiond/thread.cpp +++ b/src/bin/lttng-sessiond/thread.cpp @@ -5,21 +5,25 @@ * */ -#include "thread.h" +#include "thread.hpp" + +#include +#include +#include + +#include #include #include -#include -#include -#include -#include -static struct thread_list { +namespace { +struct thread_list { struct cds_list_head head; pthread_mutex_t lock; } thread_list = { .head = CDS_LIST_HEAD_INIT(thread_list.head), .lock = PTHREAD_MUTEX_INITIALIZER, }; +} /* namespace */ struct lttng_thread { struct urcu_ref ref; @@ -40,8 +44,7 @@ struct lttng_thread { void *data; }; -static -void lttng_thread_destroy(struct lttng_thread *thread) +static void lttng_thread_destroy(struct lttng_thread *thread) { if (thread->cleanup) { thread->cleanup(thread->data); @@ -49,14 +52,12 @@ void lttng_thread_destroy(struct lttng_thread *thread) free(thread); } -static -void lttng_thread_release(struct urcu_ref *ref) +static void lttng_thread_release(struct urcu_ref *ref) { - lttng_thread_destroy(container_of(ref, struct lttng_thread, ref)); + lttng_thread_destroy(lttng::utils::container_of(ref, <tng_thread::ref)); } -static -void *launch_thread(void *data) +static void *launch_thread(void *data) { void *ret; struct lttng_thread *thread = (struct lttng_thread *) data; @@ -69,15 +70,15 @@ void *launch_thread(void *data) } struct lttng_thread *lttng_thread_create(const char *name, - lttng_thread_entry_point entry, - lttng_thread_shutdown_cb shutdown, - lttng_thread_cleanup_cb cleanup, - void *thread_data) + lttng_thread_entry_point entry, + lttng_thread_shutdown_cb shutdown, + lttng_thread_cleanup_cb cleanup, + void *thread_data) { int ret; struct lttng_thread *thread; - thread = (lttng_thread *) zmalloc(sizeof(*thread)); + thread = zmalloc(); if (!thread) { goto error_alloc; } @@ -103,8 +104,7 @@ struct lttng_thread *lttng_thread_create(const char *name, cds_list_add(&thread->node, &thread_list.head); (void) lttng_thread_get(thread); - ret = pthread_create(&thread->thread, default_pthread_attr(), - launch_thread, thread); + ret = pthread_create(&thread->thread, default_pthread_attr(), launch_thread, thread); if (ret) { PERROR("Failed to create \"%s\" thread", thread->name); goto error_pthread_create; @@ -143,8 +143,7 @@ const char *lttng_thread_get_name(const struct lttng_thread *thread) return thread->name; } -static -bool _lttng_thread_shutdown(struct lttng_thread *thread) +static bool _lttng_thread_shutdown(struct lttng_thread *thread) { int ret; void *status; @@ -189,7 +188,7 @@ void lttng_thread_list_shutdown_orphans(void) struct lttng_thread *thread, *tmp; pthread_mutex_lock(&thread_list.lock); - cds_list_for_each_entry_safe(thread, tmp, &thread_list.head, node) { + cds_list_for_each_entry_safe (thread, tmp, &thread_list.head, node) { bool result; const long ref = uatomic_read(&thread->ref.refcount);