mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-14 01:43:33 +08:00
OTR out of line methods
This commit is contained in:
@@ -132,32 +132,47 @@ public:
|
||||
: map_(allocator)
|
||||
{ }
|
||||
|
||||
TransferID* accessOrCreate(const OutgoingTransferRegistryKey& key, MonotonicTime new_deadline)
|
||||
{
|
||||
assert(!new_deadline.isZero());
|
||||
Value* p = map_.access(key);
|
||||
if (p == NULL)
|
||||
{
|
||||
p = map_.insert(key, Value());
|
||||
if (p == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
UAVCAN_TRACE("OutgoingTransferRegistry", "Created %s", key.toString().c_str());
|
||||
}
|
||||
p->deadline = new_deadline;
|
||||
return &p->tid;
|
||||
}
|
||||
TransferID* accessOrCreate(const OutgoingTransferRegistryKey& key, MonotonicTime new_deadline);
|
||||
|
||||
bool exists(DataTypeID dtid, TransferType tt) const
|
||||
{
|
||||
return NULL != map_.findFirstKey(ExistenceCheckingPredicate(dtid, tt));
|
||||
}
|
||||
bool exists(DataTypeID dtid, TransferType tt) const;
|
||||
|
||||
void cleanup(MonotonicTime ts)
|
||||
{
|
||||
map_.removeWhere(DeadlineExpiredPredicate(ts));
|
||||
}
|
||||
void cleanup(MonotonicTime ts);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* OutgoingTransferRegistry<>
|
||||
*/
|
||||
template <int NumStaticEntries>
|
||||
TransferID* OutgoingTransferRegistry<NumStaticEntries>::accessOrCreate(const OutgoingTransferRegistryKey& key,
|
||||
MonotonicTime new_deadline)
|
||||
{
|
||||
assert(!new_deadline.isZero());
|
||||
Value* p = map_.access(key);
|
||||
if (p == NULL)
|
||||
{
|
||||
p = map_.insert(key, Value());
|
||||
if (p == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
UAVCAN_TRACE("OutgoingTransferRegistry", "Created %s", key.toString().c_str());
|
||||
}
|
||||
p->deadline = new_deadline;
|
||||
return &p->tid;
|
||||
}
|
||||
|
||||
template <int NumStaticEntries>
|
||||
bool OutgoingTransferRegistry<NumStaticEntries>::exists(DataTypeID dtid, TransferType tt) const
|
||||
{
|
||||
return NULL != map_.findFirstKey(ExistenceCheckingPredicate(dtid, tt));
|
||||
}
|
||||
|
||||
template <int NumStaticEntries>
|
||||
void OutgoingTransferRegistry<NumStaticEntries>::cleanup(MonotonicTime ts)
|
||||
{
|
||||
map_.removeWhere(DeadlineExpiredPredicate(ts));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user