Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: UAVCAN UAVCAN_Subscriber
uc_outgoing_transfer_registry.cpp
00001 /* 00002 * Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com> 00003 */ 00004 00005 #include <uavcan/transport/outgoing_transfer_registry.hpp> 00006 00007 namespace uavcan 00008 { 00009 /* 00010 * OutgoingTransferRegistryKey 00011 */ 00012 #if UAVCAN_TOSTRING 00013 std::string OutgoingTransferRegistryKey::toString() const 00014 { 00015 char buf[40]; 00016 (void)snprintf(buf, sizeof(buf), "dtid=%u tt=%u dnid=%u", 00017 int(data_type_id_.get()), int(transfer_type_), int(destination_node_id_.get())); 00018 return std::string(buf); 00019 } 00020 #endif 00021 00022 /* 00023 * OutgoingTransferRegistry 00024 */ 00025 const MonotonicDuration OutgoingTransferRegistry::MinEntryLifetime = MonotonicDuration::fromMSec(2000); 00026 00027 TransferID* OutgoingTransferRegistry::accessOrCreate(const OutgoingTransferRegistryKey& key, 00028 MonotonicTime new_deadline) 00029 { 00030 UAVCAN_ASSERT(!new_deadline.isZero()); 00031 Value* p = map_.access(key); 00032 if (p == UAVCAN_NULLPTR) 00033 { 00034 p = map_.insert(key, Value()); 00035 if (p == UAVCAN_NULLPTR) 00036 { 00037 return UAVCAN_NULLPTR; 00038 } 00039 UAVCAN_TRACE("OutgoingTransferRegistry", "Created %s", key.toString().c_str()); 00040 } 00041 p->deadline = new_deadline; 00042 return &p->tid; 00043 } 00044 00045 bool OutgoingTransferRegistry::exists(DataTypeID dtid, TransferType tt) const 00046 { 00047 return UAVCAN_NULLPTR != map_.find(ExistenceCheckingPredicate(dtid, tt)); 00048 } 00049 00050 void OutgoingTransferRegistry::cleanup(MonotonicTime ts) 00051 { 00052 map_.removeAllWhere(DeadlineExpiredPredicate(ts)); 00053 } 00054 00055 }
Generated on Tue Jul 12 2022 17:17:35 by
1.7.2