Skip to content

Commit 0ddd1d9

Browse files
committed
Make Thread methods const
1 parent 1330eee commit 0ddd1d9

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

rtos/Thread.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ osStatus Thread::set_priority(osPriority priority)
178178
return ret;
179179
}
180180

181-
osPriority Thread::get_priority()
181+
osPriority Thread::get_priority() const
182182
{
183183
osPriority_t ret;
184184
_mutex.lock();
@@ -201,7 +201,7 @@ int32_t Thread::signal_set(int32_t flags)
201201
return osThreadFlagsSet(_tid, flags);
202202
}
203203

204-
Thread::State Thread::get_state()
204+
Thread::State Thread::get_state() const
205205
{
206206
uint8_t state = osThreadTerminated;
207207

@@ -267,7 +267,7 @@ Thread::State Thread::get_state()
267267
return user_state;
268268
}
269269

270-
uint32_t Thread::stack_size()
270+
uint32_t Thread::stack_size() const
271271
{
272272
uint32_t size = 0;
273273
_mutex.lock();
@@ -280,7 +280,7 @@ uint32_t Thread::stack_size()
280280
return size;
281281
}
282282

283-
uint32_t Thread::free_stack()
283+
uint32_t Thread::free_stack() const
284284
{
285285
uint32_t size = 0;
286286
_mutex.lock();
@@ -296,7 +296,7 @@ uint32_t Thread::free_stack()
296296
return size;
297297
}
298298

299-
uint32_t Thread::used_stack()
299+
uint32_t Thread::used_stack() const
300300
{
301301
uint32_t size = 0;
302302
_mutex.lock();
@@ -312,7 +312,7 @@ uint32_t Thread::used_stack()
312312
return size;
313313
}
314314

315-
uint32_t Thread::max_stack()
315+
uint32_t Thread::max_stack() const
316316
{
317317
uint32_t size = 0;
318318
_mutex.lock();
@@ -334,7 +334,7 @@ uint32_t Thread::max_stack()
334334
return size;
335335
}
336336

337-
const char *Thread::get_name()
337+
const char *Thread::get_name() const
338338
{
339339
return _attr.name;
340340
}

rtos/Thread.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ class Thread : private mbed::NonCopyable<Thread> {
305305
306306
@note You cannot call this function from ISR context.
307307
*/
308-
osPriority get_priority();
308+
osPriority get_priority() const;
309309

310310
/** Set the specified Thread Flags for the thread.
311311
@param flags specifies the flags of the thread that should be set.
@@ -356,42 +356,42 @@ class Thread : private mbed::NonCopyable<Thread> {
356356
357357
@note You cannot call this function from ISR context.
358358
*/
359-
State get_state();
359+
State get_state() const;
360360

361361
/** Get the total stack memory size for this Thread
362362
@return the total stack memory size in bytes
363363
364364
@note You cannot call this function from ISR context.
365365
*/
366-
uint32_t stack_size();
366+
uint32_t stack_size() const;
367367

368368
/** Get the currently unused stack memory for this Thread
369369
@return the currently unused stack memory in bytes
370370
371371
@note You cannot call this function from ISR context.
372372
*/
373-
uint32_t free_stack();
373+
uint32_t free_stack() const;
374374

375375
/** Get the currently used stack memory for this Thread
376376
@return the currently used stack memory in bytes
377377
378378
@note You cannot call this function from ISR context.
379379
*/
380-
uint32_t used_stack();
380+
uint32_t used_stack() const;
381381

382382
/** Get the maximum stack memory usage to date for this Thread
383383
@return the maximum stack memory usage to date in bytes
384384
385385
@note You cannot call this function from ISR context.
386386
*/
387-
uint32_t max_stack();
387+
uint32_t max_stack() const;
388388

389389
/** Get thread name
390390
@return thread name or NULL if the name was not set.
391391
392392
@note You may call this function from ISR context.
393393
*/
394-
const char *get_name();
394+
const char *get_name() const;
395395

396396
/** Get thread id
397397
@return thread ID for reference by other functions.
@@ -536,7 +536,7 @@ class Thread : private mbed::NonCopyable<Thread> {
536536
osThreadAttr_t _attr;
537537
bool _dynamic_stack;
538538
Semaphore _join_sem;
539-
Mutex _mutex;
539+
mutable Mutex _mutex;
540540
mbed_rtos_storage_thread_t _obj_mem;
541541
bool _finished;
542542
};

0 commit comments

Comments
 (0)