Merge pull request #8961 from marcemmers/this-thread

ThisThread get_name()
pull/9131/head
Cruz Monrreal 2018-12-14 11:13:31 -06:00 committed by GitHub
commit 463a4536e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -138,4 +138,13 @@ osThreadId_t ThisThread::get_id()
return osThreadGetId(); return osThreadGetId();
} }
const char *get_name()
{
osThreadId_t id = osThreadGetId();
if (id == NULL) {
return NULL;
}
return osThreadGetName(id);
}
} }

View File

@ -179,6 +179,12 @@ void yield();
*/ */
osThreadId_t get_id(); osThreadId_t get_id();
/** Get the thread name of the current running thread.
@return thread name pointer or NULL if thread has no name or in case of error.
@note You cannot call this function from ISR context.
*/
const char *get_name();
}; };
/** @}*/ /** @}*/
/** @}*/ /** @}*/