artf4107: GetInstance() calls are now atomic

C++11 guarantees construction of static variables to be atomic, so this patch takes advantage of that.

Change-Id: I4a3db0f19c5fa5461fef3b6b63d7b8fec596c962
This commit is contained in:
Tyler Veness
2015-06-24 04:25:10 -07:00
parent 368ad30d37
commit faedfa6ed4
11 changed files with 14 additions and 43 deletions

View File

@@ -10,13 +10,10 @@
#include <netdb.h>
constexpr uint8_t CameraServer::kMagicNumber[];
CameraServer* CameraServer::s_instance = nullptr;
CameraServer* CameraServer::GetInstance() {
if (s_instance == nullptr) {
s_instance = new CameraServer;
}
return s_instance;
static CameraServer instance;
return &instance;
}
CameraServer::CameraServer()