made sure everything's thread safe
Pretty much everything already was, but I tweaked a few things to make
sure they stay that way and added various comments about that fact. Also
cleaned up a few things along the way and removed SafeMessageBuilder
because it wasn't.
diff --git a/aos/common/die.cc b/aos/common/die.cc
index e1b3b07..69b2aef 100644
--- a/aos/common/die.cc
+++ b/aos/common/die.cc
@@ -10,6 +10,7 @@
#include <stdint.h>
#include <string>
+#include <atomic>
namespace aos {
@@ -45,7 +46,7 @@
#endif
}
-bool test_mode = false;
+::std::atomic_bool test_mode(false);
} // namespace
@@ -57,7 +58,7 @@
fputs("aos fatal: ERROR!! details following\n", stderr);
va_copy(args1, args_in);
vfprintf(stderr, format, args1);
- if (!test_mode) {
+ if (!test_mode.load()) {
fputs("aos fatal: ERROR!! see stderr for details\n", stdout);
const std::string filename = GetFilename();
@@ -78,7 +79,7 @@
}
void SetDieTestMode(bool new_test_mode) {
- test_mode = new_test_mode;
+ test_mode.store(new_test_mode);
}
} // namespace aos