allow passing context to mutex guard
This commit is contained in:
parent
511d07c0c7
commit
f84097543e
@ -7,14 +7,17 @@
|
|||||||
class MutexGuard {
|
class MutexGuard {
|
||||||
public:
|
public:
|
||||||
MutexGuard(MutexIF* mutex, MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::BLOCKING,
|
MutexGuard(MutexIF* mutex, MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::BLOCKING,
|
||||||
uint32_t timeoutMs = 0)
|
uint32_t timeoutMs = 0, const char* context = nullptr)
|
||||||
: internalMutex(mutex) {
|
: internalMutex(mutex) {
|
||||||
|
if (context == nullptr) {
|
||||||
|
context = "unknown";
|
||||||
|
}
|
||||||
if (mutex == nullptr) {
|
if (mutex == nullptr) {
|
||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "MutexGuard: Passed mutex is invalid!" << std::endl;
|
sif::error << "MutexGuard::" << context << ": Passed mutex is invalid!" << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printError("MutexGuard: Passed mutex is invalid!\n");
|
sif::printError("MutexGuard::%s: Passed mutex is invalid!\n", context);
|
||||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user