The end goal being that all of our multi threaded code be safe, and easy to use. So far we rely too much on manual thinking & a global lock around the robot object in my opinion. This pull request adds checks for thread safety, and makes some modules thread safe.
From the first commit:
This commit adds a lock to the trajectory_manager object and makes it
public API thread safe. This means it should now be easier to write code
that uses it in a safe way, as well as suppress weird corner cases, like
having to call traj_hardstop() 10 times for the robot to actually stop.
This also introduces machine checks for thread correctness: the code has
thread safety annotations [0] and they are checked by supported
compilers (recent clang versions).
Safety analysis does not strictly require using C++, but is way more
comfortable to use in that language, due to Abseil's support for it. In
addition, using MutexLock objects make the code easier to read and also
make it harder to write incorrect code. I believe the advantages far
outweigh the issues with C++.
The end goal being that all of our multi threaded code be safe, and easy to use. So far we rely too much on manual thinking & a global lock around the
robot
object in my opinion. This pull request adds checks for thread safety, and makes some modules thread safe.From the first commit:
This commit adds a lock to the trajectory_manager object and makes it public API thread safe. This means it should now be easier to write code that uses it in a safe way, as well as suppress weird corner cases, like having to call traj_hardstop() 10 times for the robot to actually stop.
This also introduces machine checks for thread correctness: the code has thread safety annotations [0] and they are checked by supported compilers (recent clang versions).
Safety analysis does not strictly require using C++, but is way more comfortable to use in that language, due to Abseil's support for it. In addition, using MutexLock objects make the code easier to read and also make it harder to write incorrect code. I believe the advantages far outweigh the issues with C++.
[0] https://clang.llvm.org/docs/ThreadSafetyAnalysis.html