OTR deinterfaced

This commit is contained in:
Pavel Kirienko
2015-10-14 20:15:19 +03:00
parent 0d5fc65907
commit 899aae44f7
10 changed files with 56 additions and 97 deletions
@@ -20,8 +20,36 @@ std::string OutgoingTransferRegistryKey::toString() const
#endif
/*
* IOutgoingTransferRegistry
* OutgoingTransferRegistry
*/
const MonotonicDuration IOutgoingTransferRegistry::MinEntryLifetime = MonotonicDuration::fromMSec(2000);
const MonotonicDuration OutgoingTransferRegistry::MinEntryLifetime = MonotonicDuration::fromMSec(2000);
TransferID* OutgoingTransferRegistry::accessOrCreate(const OutgoingTransferRegistryKey& key,
MonotonicTime new_deadline)
{
UAVCAN_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;
}
bool OutgoingTransferRegistry::exists(DataTypeID dtid, TransferType tt) const
{
return NULL != map_.find(ExistenceCheckingPredicate(dtid, tt));
}
void OutgoingTransferRegistry::cleanup(MonotonicTime ts)
{
map_.removeAllWhere(DeadlineExpiredPredicate(ts));
}
}
@@ -153,7 +153,7 @@ int TransferSender::send(const uint8_t* payload, unsigned payload_len, Monotonic
UAVCAN_ASSERT(!tx_deadline.isZero());
const MonotonicTime otr_deadline = tx_deadline + max(max_transfer_interval_ * 2,
IOutgoingTransferRegistry::MinEntryLifetime);
OutgoingTransferRegistry::MinEntryLifetime);
TransferID* const tid = dispatcher_.getOutgoingTransferRegistry().accessOrCreate(otr_key, otr_deadline);
if (tid == NULL)