A RAII wrapper for mutexes which locks them at the beginning of its lifetime and releases them at the end of its lifetime (normally the scope in which the wrapper was created).
More...
A RAII wrapper for mutexes which locks them at the beginning of its lifetime and releases them at the end of its lifetime (normally the scope in which the wrapper was created).
To create a smart mutex, just do:
smart_mutex(SemaphoreHandle_t mutex)
Definition smart_mutex.h:27
Done! Now, the mutex will stay locked until the function finishes (until this object goes out of scope and its destructor is called) and then it will automatically unlock the mutex for you. Be careful that you don't lock the mutex and then call a function which again locks the mutex, which will cause the firmware to hang!!