mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-31 06:51:35 +08:00
Fixed GDTR singleton (http://stackoverflow.com/questions/22985570)
This commit is contained in:
@@ -60,6 +60,12 @@ private:
|
|||||||
mutable List srvs_;
|
mutable List srvs_;
|
||||||
bool frozen_;
|
bool frozen_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We can't use function local static variable for singleton because of code size issues:
|
||||||
|
* http://stackoverflow.com/questions/22985570
|
||||||
|
*/
|
||||||
|
static GlobalDataTypeRegistry singleton;
|
||||||
|
|
||||||
GlobalDataTypeRegistry() : frozen_(false) { }
|
GlobalDataTypeRegistry() : frozen_(false) { }
|
||||||
|
|
||||||
List* selectList(DataTypeKind kind) const;
|
List* selectList(DataTypeKind kind) const;
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
namespace uavcan
|
namespace uavcan
|
||||||
{
|
{
|
||||||
|
|
||||||
|
GlobalDataTypeRegistry GlobalDataTypeRegistry::singleton;
|
||||||
|
|
||||||
GlobalDataTypeRegistry::List* GlobalDataTypeRegistry::selectList(DataTypeKind kind) const
|
GlobalDataTypeRegistry::List* GlobalDataTypeRegistry::selectList(DataTypeKind kind) const
|
||||||
{
|
{
|
||||||
if (kind == DataTypeKindMessage)
|
if (kind == DataTypeKindMessage)
|
||||||
@@ -115,8 +117,7 @@ GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::registImpl(Entry* d
|
|||||||
|
|
||||||
GlobalDataTypeRegistry& GlobalDataTypeRegistry::instance()
|
GlobalDataTypeRegistry& GlobalDataTypeRegistry::instance()
|
||||||
{
|
{
|
||||||
static GlobalDataTypeRegistry inst;
|
return singleton;
|
||||||
return inst;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalDataTypeRegistry::freeze()
|
void GlobalDataTypeRegistry::freeze()
|
||||||
|
|||||||
Reference in New Issue
Block a user