mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
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:
@@ -10,10 +10,8 @@ using namespace gazebo;
|
||||
class MainNode {
|
||||
public:
|
||||
static MainNode* GetInstance() {
|
||||
if (instance == nullptr) {
|
||||
instance = new MainNode();
|
||||
}
|
||||
return instance;
|
||||
static MainNode instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
template<typename M>
|
||||
@@ -39,8 +37,6 @@ public:
|
||||
|
||||
transport::NodePtr main;
|
||||
private:
|
||||
static MainNode* instance;
|
||||
|
||||
MainNode() {
|
||||
gazebo::transport::init();
|
||||
main = transport::NodePtr(new transport::Node());
|
||||
|
||||
Reference in New Issue
Block a user