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: mbed-os-example-mros2 example-mbed-mros2-sub-pose example-mbed-mros2-pub-twist example-mbed-mros2-mturtle-teleop
StatefulWriter.h
00001 /* 00002 The MIT License 00003 Copyright (c) 2019 Lehrstuhl Informatik 11 - RWTH Aachen University 00004 Permission is hereby granted, free of charge, to any person obtaining a copy 00005 of this software and associated documentation files (the "Software"), to deal 00006 in the Software without restriction, including without limitation the rights 00007 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 copies of the Software, and to permit persons to whom the Software is 00009 furnished to do so, subject to the following conditions: 00010 The above copyright notice and this permission notice shall be included in 00011 all copies or substantial portions of the Software. 00012 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00013 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00014 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00015 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00016 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00017 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00018 THE SOFTWARE 00019 00020 This file is part of embeddedRTPS. 00021 00022 Author: i11 - Embedded Software, RWTH Aachen University 00023 */ 00024 00025 #ifndef RTPS_STATEFULWRITER_H 00026 #define RTPS_STATEFULWRITER_H 00027 00028 #include "rtps/entities/ReaderProxy.h" 00029 #include "rtps/entities/Writer.h" 00030 #include "rtps/storages/MemoryPool.h" 00031 #include "rtps/storages/SimpleHistoryCache.h" 00032 00033 00034 00035 namespace rtps { 00036 00037 template <class NetworkDriver> class StatefulWriterT final : public Writer { 00038 public: 00039 ~StatefulWriterT() override; 00040 bool init(TopicData attributes, TopicKind_t topicKind, ThreadPool *threadPool, 00041 NetworkDriver &driver); 00042 00043 bool addNewMatchedReader(const ReaderProxy &newProxy) override; 00044 void removeReader(const Guid &guid) override; 00045 //! Executes required steps like sending packets. Intended to be called by 00046 //! worker threads 00047 void progress() override; 00048 const CacheChange *newChange(ChangeKind_t kind, const uint8_t *data, 00049 DataSize_t size) override; 00050 void setAllChangesToUnsent() override; 00051 void onNewAckNack(const SubmessageAckNack &msg, 00052 const GuidPrefix_t &sourceGuidPrefix) override; 00053 00054 private: 00055 sys_mutex_t m_mutex; 00056 ThreadPool *mp_threadPool = nullptr; 00057 00058 PacketInfo m_packetInfo; 00059 NetworkDriver *m_transport; 00060 00061 TopicKind_t m_topicKind = TopicKind_t::NO_KEY; 00062 SequenceNumber_t m_nextSequenceNumberToSend = {0, 1}; 00063 SimpleHistoryCache m_history; 00064 sys_thread_t m_heartbeatThread; 00065 Count_t m_hbCount{1}; 00066 00067 bool m_running = true; 00068 00069 MemoryPool<ReaderProxy, Config::NUM_READER_PROXIES_PER_WRITER> m_proxies; 00070 00071 bool sendData(const ReaderProxy &reader, const SequenceNumber_t &sn); 00072 void sendHeartBeatLoop(); 00073 void sendHeartBeat(); 00074 bool isIrrelevant(ChangeKind_t kind) const; 00075 static void hbFunctionJumppad(void *thisPointer); 00076 }; 00077 00078 using StatefulWriter = StatefulWriterT<UdpDriver>; 00079 } // namespace rtps 00080 extern void *networkSubDriverPtr; 00081 extern void *networkPubDriverPtr; 00082 extern void (*hbPubFuncPtr)(void *); 00083 extern void (*hbSubFuncPtr)(void *); 00084 extern "C" void callHbPubFunc(void *arg); 00085 extern "C" void callHbSubFunc(void *arg); 00086 #include "StatefulWriter.tpp" 00087 00088 #endif // RTPS_STATEFULWRITER_H
Generated on Sun Jul 31 2022 04:49:48 by
1.7.2