Added get_name function to ThisThread namespace

pull/8961/head
Marc Emmers 2018-12-04 11:31:20 +01:00
parent c1c94c83c5
commit 2f792a9c88
2 changed files with 15 additions and 0 deletions

View File

@ -138,4 +138,13 @@ osThreadId_t ThisThread::get_id()
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();
/** 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();
};
/** @}*/
/** @}*/