@@ -41,82 +41,25 @@ class HandlerList {
4141 // / @param _msgid ID of the message/service
4242 // / @param _signature Signature of the message/service
4343 // / @param _index Index of the handler list
44- HandlerList (CanardTransferType _transfer_type, uint16_t _msgid, uint64_t _signature, uint8_t _index) NOINLINE_FUNC :
45- index (_index) {
46- if (index >= CANARD_NUM_HANDLERS) {
47- return ;
48- }
49- #ifdef WITH_SEMAPHORE
50- WITH_SEMAPHORE (sem[index]);
51- #endif
52- next = head[index];
53- head[index] = this ;
54- msgid = _msgid;
55- signature = _signature;
56- transfer_type = _transfer_type;
57- }
44+ HandlerList (CanardTransferType _transfer_type, uint16_t _msgid, uint64_t _signature, uint8_t _index) NOINLINE_FUNC;
5845
5946 // / @brief delete copy constructor and assignment operator
6047 HandlerList (const HandlerList&) = delete ;
6148
6249 // destructor, remove the entry from the singly-linked list
63- virtual ~HandlerList () NOINLINE_FUNC {
64- #ifdef WITH_SEMAPHORE
65- WITH_SEMAPHORE (sem[index]);
66- #endif
67- HandlerList* entry = head[index];
68- if (entry == this ) {
69- head[index] = next;
70- return ;
71- }
72- while (entry != nullptr ) {
73- if (entry->next == this ) {
74- entry->next = next;
75- return ;
76- }
77- entry = entry->next ;
78- }
79- }
50+ virtual ~HandlerList () NOINLINE_FUNC;
8051
8152 // / @brief accept a message if it is handled by this handler list
8253 // / @param index Index of the handler list
8354 // / @param msgid ID of the message/service
8455 // / @param[out] signature Signature of the message/service
8556 // / @return true if the message is handled by this handler list
86- static bool accept_message (uint8_t index, uint16_t msgid, uint64_t &signature) NOINLINE_FUNC
87- {
88- #ifdef WITH_SEMAPHORE
89- WITH_SEMAPHORE (sem[index]);
90- #endif
91- HandlerList* entry = head[index];
92- while (entry != nullptr ) {
93- if (entry->msgid == msgid) {
94- signature = entry->signature ;
95- return true ;
96- }
97- entry = entry->next ;
98- }
99- return false ;
100- }
57+ static bool accept_message (uint8_t index, uint16_t msgid, uint64_t &signature) NOINLINE_FUNC;
10158
10259 // / @brief handle a message if it is handled by this handler list
10360 // / @param index Index of the handler list
10461 // / @param transfer transfer object of the request
105- static void handle_message (uint8_t index, const CanardRxTransfer& transfer) NOINLINE_FUNC
106- {
107- #ifdef WITH_SEMAPHORE
108- WITH_SEMAPHORE (sem[index]);
109- #endif
110- HandlerList* entry = head[index];
111- while (entry != nullptr ) {
112- if (transfer.data_type_id == entry->msgid &&
113- entry->transfer_type == transfer.transfer_type ) {
114- entry->handle_message (transfer);
115- return ;
116- }
117- entry = entry->next ;
118- }
119- }
62+ static void handle_message (uint8_t index, const CanardRxTransfer& transfer) NOINLINE_FUNC;
12063
12164 // / @brief Method to handle a message implemented by the derived class
12265 // / @param transfer transfer object of the request
@@ -128,7 +71,7 @@ class HandlerList {
12871
12972private:
13073 static HandlerList* head[CANARD_NUM_HANDLERS];
131- #ifdef WITH_SEMAPHORE
74+ #ifdef CANARD_MUTEX_ENABLED
13275 static Canard::Semaphore sem[CANARD_NUM_HANDLERS];
13376#endif
13477 uint16_t msgid;
0 commit comments