netstar pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=981e85f99cdb1c1945d57256f8d1448168610573

commit 981e85f99cdb1c1945d57256f8d1448168610573
Author: Alastair Poole <m...@alastairpoole.com>
Date:   Sat Dec 4 06:36:36 2021 +0000

    ecore_thread: Add ecore_thread_name_set API.
    
    This function can only be successfully called from the given
    thread. For debugging purposes, it's useful to be able to give
    a name to an Ecore_Thread.
    
    ecore_thread_name_set(Ecore_Thread *thread, const char *name);
    
    @feature
---
 src/lib/ecore/Ecore_Common.h | 14 ++++++++++++++
 src/lib/ecore/ecore_thread.c | 13 +++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/src/lib/ecore/Ecore_Common.h b/src/lib/ecore/Ecore_Common.h
index 899debc267..af4950c6cd 100644
--- a/src/lib/ecore/Ecore_Common.h
+++ b/src/lib/ecore/Ecore_Common.h
@@ -2080,6 +2080,20 @@ EAPI void ecore_thread_max_reset(void);
  */
 EAPI int ecore_thread_available_get(void);
 
+/**
+ * Sets the name of a given thread for debugging purposes.
+ *
+ * This function will only succeed if called from the named thread.
+ *
+ * @param thread The thread context to set the name of
+ * @param name The string to name the thread - this cannot be NULL
+ *
+ * @return EINA_TRUE if it succeeds setting the name or EINA_FALSE otherwise.
+ *
+ * @since 1.26
+ */
+EAPI Eina_Bool ecore_thread_name_set(Ecore_Thread *thread, const char *name);
+
 /**
  * Adds some data to a hash local to the thread.
  *
diff --git a/src/lib/ecore/ecore_thread.c b/src/lib/ecore/ecore_thread.c
index f38c7880c1..c112b77676 100644
--- a/src/lib/ecore/ecore_thread.c
+++ b/src/lib/ecore/ecore_thread.c
@@ -1237,6 +1237,19 @@ ecore_thread_available_get(void)
    return ret;
 }
 
+EAPI Eina_Bool
+ecore_thread_name_set(Ecore_Thread *thread, const char *name)
+{
+   Ecore_Pthread_Worker *work = (Ecore_Pthread_Worker *) thread;
+
+   if ((!work) || (!work->self) || (!name))
+     return EINA_FALSE;
+
+   if (eina_thread_self() != work->self) return EINA_FALSE;
+
+   return eina_thread_name_set(work->self, name);
+}
+
 EAPI Eina_Bool
 ecore_thread_local_data_add(Ecore_Thread *thread,
                             const char *key,

-- 


Reply via email to