File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 27
27
28
28
namespace rtos {
29
29
30
- Mutex::Mutex () {
30
+ Mutex::Mutex ()
31
+ {
32
+ constructor ();
33
+ }
34
+
35
+ Mutex::Mutex (const char *name)
36
+ {
37
+ constructor (name);
38
+ }
39
+
40
+ void Mutex::constructor (const char *name)
41
+ {
31
42
memset (&_obj_mem, 0 , sizeof (_obj_mem));
32
43
memset (&_attr, 0 , sizeof (_attr));
44
+ _attr.name = name ? name : " aplication_unnamed_mutex" ;
33
45
_attr.cb_mem = &_obj_mem;
34
46
_attr.cb_size = sizeof (_obj_mem);
35
47
_attr.attr_bits = osMutexRecursive;
Original file line number Diff line number Diff line change @@ -43,6 +43,12 @@ class Mutex {
43
43
/* * Create and Initialize a Mutex object */
44
44
Mutex ();
45
45
46
+ /* * Create and Initialize a Mutex object
47
+
48
+ @param name name to be used for this mutex. It has to stay allocated for the lifetime of the thread.
49
+ */
50
+ Mutex (const char *name);
51
+
46
52
/* * Wait until a Mutex becomes available.
47
53
@param millisec timeout value or 0 in case of no time-out. (default: osWaitForever)
48
54
@return status code that indicates the execution status of the function.
@@ -62,6 +68,8 @@ class Mutex {
62
68
~Mutex ();
63
69
64
70
private:
71
+ void constructor (const char *name = NULL );
72
+
65
73
osMutexId_t _id;
66
74
osMutexAttr_t _attr;
67
75
mbed_rtos_storage_mutex_t _obj_mem;
You can’t perform that action at this time.
0 commit comments