mirror of https://github.com/ARMmbed/mbed-os.git
Add name parameter for C++ mutex wrapper
parent
e66f9ee818
commit
0064df1ce6
|
@ -27,9 +27,21 @@
|
||||||
|
|
||||||
namespace rtos {
|
namespace rtos {
|
||||||
|
|
||||||
Mutex::Mutex() {
|
Mutex::Mutex()
|
||||||
|
{
|
||||||
|
constructor();
|
||||||
|
}
|
||||||
|
|
||||||
|
Mutex::Mutex(const char *name)
|
||||||
|
{
|
||||||
|
constructor(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mutex::constructor(const char *name)
|
||||||
|
{
|
||||||
memset(&_obj_mem, 0, sizeof(_obj_mem));
|
memset(&_obj_mem, 0, sizeof(_obj_mem));
|
||||||
memset(&_attr, 0, sizeof(_attr));
|
memset(&_attr, 0, sizeof(_attr));
|
||||||
|
_attr.name = name ? name : "aplication_unnamed_mutex";
|
||||||
_attr.cb_mem = &_obj_mem;
|
_attr.cb_mem = &_obj_mem;
|
||||||
_attr.cb_size = sizeof(_obj_mem);
|
_attr.cb_size = sizeof(_obj_mem);
|
||||||
_attr.attr_bits = osMutexRecursive;
|
_attr.attr_bits = osMutexRecursive;
|
||||||
|
|
|
@ -43,6 +43,12 @@ public:
|
||||||
/** Create and Initialize a Mutex object */
|
/** Create and Initialize a Mutex object */
|
||||||
Mutex();
|
Mutex();
|
||||||
|
|
||||||
|
/** Create and Initialize a Mutex object
|
||||||
|
|
||||||
|
@param name name to be used for this mutex. It has to stay allocated for the lifetime of the thread.
|
||||||
|
*/
|
||||||
|
Mutex(const char *name);
|
||||||
|
|
||||||
/** Wait until a Mutex becomes available.
|
/** Wait until a Mutex becomes available.
|
||||||
@param millisec timeout value or 0 in case of no time-out. (default: osWaitForever)
|
@param millisec timeout value or 0 in case of no time-out. (default: osWaitForever)
|
||||||
@return status code that indicates the execution status of the function.
|
@return status code that indicates the execution status of the function.
|
||||||
|
@ -62,6 +68,8 @@ public:
|
||||||
~Mutex();
|
~Mutex();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void constructor(const char *name = NULL);
|
||||||
|
|
||||||
osMutexId_t _id;
|
osMutexId_t _id;
|
||||||
osMutexAttr_t _attr;
|
osMutexAttr_t _attr;
|
||||||
mbed_rtos_storage_mutex_t _obj_mem;
|
mbed_rtos_storage_mutex_t _obj_mem;
|
||||||
|
|
Loading…
Reference in New Issue