Skip to content

Commit 463a453

Browse files
author
Cruz Monrreal
authored
Merge pull request #8961 from marcemmers/this-thread
ThisThread get_name()
2 parents 64e7e46 + 2f792a9 commit 463a453

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

rtos/ThisThread.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,13 @@ osThreadId_t ThisThread::get_id()
138138
return osThreadGetId();
139139
}
140140

141+
const char *get_name()
142+
{
143+
osThreadId_t id = osThreadGetId();
144+
if (id == NULL) {
145+
return NULL;
146+
}
147+
return osThreadGetName(id);
148+
}
149+
141150
}

rtos/ThisThread.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ void yield();
179179
*/
180180
osThreadId_t get_id();
181181

182+
/** Get the thread name of the current running thread.
183+
@return thread name pointer or NULL if thread has no name or in case of error.
184+
@note You cannot call this function from ISR context.
185+
*/
186+
const char *get_name();
187+
182188
};
183189
/** @}*/
184190
/** @}*/

0 commit comments

Comments
 (0)