mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
Fixed GDTR singleton (http://stackoverflow.com/questions/22985570)
This commit is contained in:
parent
d0b541e22d
commit
c26c320dd9
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user