jonenz / FreeRTOS-Cpp

C++17 header-only interface to the FreeRTOS kernel API.
https://jonenz.github.io/FreeRTOS-Cpp
MIT License
48 stars 10 forks source link

RAII wrappers for mutex and critical section #9

Open electretmike opened 1 year ago

electretmike commented 1 year ago

It would be nice if there were RAII wrappers for mutex and ciritical section. Using them could look like:

{
  CiriticalSection cs;
  // Do things inside critical section
}

Same for a mutex:

{
  MutexLock lock(mutex);
  // Do things protected by mutex
}

Would something like that be in scope for this library?

jonenz commented 1 year ago

I would like to keep this out of the core part of the library since it doesn't directly interface with an existing FreeRTOS interface, but I'm open to adding it to the repo in a higher layer. Having a section of the library that implements some of these higher level C++ patterns/concepts would be very useful.