summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlastair Poole <mail@alastairpoole.com>2021-12-04 06:36:36 +0000
committerAlastair Poole <mail@alastairpoole.com>2021-12-04 06:36:36 +0000
commit981e85f99cdb1c1945d57256f8d1448168610573 (patch)
tree2ddf2eb2f088fe2b6ba536146811115dc07222dd
parentd5c8311470e398421d960bd6109051f5f59d2ea3 (diff)
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
-rw-r--r--src/lib/ecore/Ecore_Common.h14
-rw-r--r--src/lib/ecore/ecore_thread.c13
2 files changed, 27 insertions, 0 deletions
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
@@ -2081,6 +2081,20 @@ EAPI void ecore_thread_max_reset(void);
2081EAPI int ecore_thread_available_get(void); 2081EAPI int ecore_thread_available_get(void);
2082 2082
2083/** 2083/**
2084 * Sets the name of a given thread for debugging purposes.
2085 *
2086 * This function will only succeed if called from the named thread.
2087 *
2088 * @param thread The thread context to set the name of
2089 * @param name The string to name the thread - this cannot be NULL
2090 *
2091 * @return EINA_TRUE if it succeeds setting the name or EINA_FALSE otherwise.
2092 *
2093 * @since 1.26
2094 */
2095EAPI Eina_Bool ecore_thread_name_set(Ecore_Thread *thread, const char *name);
2096
2097/**
2084 * Adds some data to a hash local to the thread. 2098 * Adds some data to a hash local to the thread.
2085 * 2099 *
2086 * @param thread The thread context the data belongs to 2100 * @param thread The thread context the data belongs to
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
@@ -1238,6 +1238,19 @@ ecore_thread_available_get(void)
1238} 1238}
1239 1239
1240EAPI Eina_Bool 1240EAPI Eina_Bool
1241ecore_thread_name_set(Ecore_Thread *thread, const char *name)
1242{
1243 Ecore_Pthread_Worker *work = (Ecore_Pthread_Worker *) thread;
1244
1245 if ((!work) || (!work->self) || (!name))
1246 return EINA_FALSE;
1247
1248 if (eina_thread_self() != work->self) return EINA_FALSE;
1249
1250 return eina_thread_name_set(work->self, name);
1251}
1252
1253EAPI Eina_Bool
1241ecore_thread_local_data_add(Ecore_Thread *thread, 1254ecore_thread_local_data_add(Ecore_Thread *thread,
1242 const char *key, 1255 const char *key,
1243 void *value, 1256 void *value,