mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-08 11:58:52 +08:00
Fixed GDTR singleton (http://stackoverflow.com/questions/22985570)
This commit is contained in:
@@ -60,6 +60,12 @@ private:
|
||||
mutable List srvs_;
|
||||
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) { }
|
||||
|
||||
List* selectList(DataTypeKind kind) const;
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
namespace uavcan
|
||||
{
|
||||
|
||||
GlobalDataTypeRegistry GlobalDataTypeRegistry::singleton;
|
||||
|
||||
GlobalDataTypeRegistry::List* GlobalDataTypeRegistry::selectList(DataTypeKind kind) const
|
||||
{
|
||||
if (kind == DataTypeKindMessage)
|
||||
@@ -115,8 +117,7 @@ GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::registImpl(Entry* d
|
||||
|
||||
GlobalDataTypeRegistry& GlobalDataTypeRegistry::instance()
|
||||
{
|
||||
static GlobalDataTypeRegistry inst;
|
||||
return inst;
|
||||
return singleton;
|
||||
}
|
||||
|
||||
void GlobalDataTypeRegistry::freeze()
|
||||
|
||||
Reference in New Issue
Block a user