@@ -42,7 +42,7 @@ class Subscriber : public HandlerList {
4242 HandlerList (CanardTransferTypeBroadcast, msgtype::cxx_iface::ID, msgtype::cxx_iface::SIGNATURE, _index),
4343 cb (_cb) {
4444#ifdef CANARD_MUTEX_ENABLED
45- WITH_SEMAPHORE (sem[index] );
45+ WITH_SEMAPHORE (get_sem () );
4646#endif
4747 next = branch_head[index];
4848 branch_head[index] = this ;
@@ -53,6 +53,9 @@ class Subscriber : public HandlerList {
5353
5454 // destructor, remove the entry from the singly-linked list
5555 ~Subscriber () {
56+ #ifdef CANARD_MUTEX_ENABLED
57+ WITH_SEMAPHORE (get_sem ());
58+ #endif
5659 Subscriber<msgtype>* entry = branch_head[index];
5760 if (entry == this ) {
5861 branch_head[index] = next;
@@ -70,6 +73,9 @@ class Subscriber : public HandlerList {
7073 // / @brief parse the message and call the callback
7174 // / @param transfer transfer object
7275 void handle_message (const CanardRxTransfer& transfer) override {
76+ #ifdef CANARD_MUTEX_ENABLED
77+ WITH_SEMAPHORE (get_sem ());
78+ #endif
7379 msgtype msg {};
7480 if (msgtype::cxx_iface::decode (&transfer, &msg)) {
7581 // invalid decode
@@ -86,20 +92,12 @@ class Subscriber : public HandlerList {
8692private:
8793 Subscriber<msgtype>* next;
8894 static Subscriber<msgtype> *branch_head[CANARD_NUM_HANDLERS];
89- #ifdef CANARD_MUTEX_ENABLED
90- static Canard::Semaphore sem[CANARD_NUM_HANDLERS];
91- #endif
9295 Callback<msgtype> &cb;
9396};
9497
9598template <typename msgtype>
9699Subscriber<msgtype>* Subscriber<msgtype>::branch_head[] = {nullptr };
97100
98- #ifdef CANARD_MUTEX_ENABLED
99- template <typename msgtype>
100- Canard::Semaphore Subscriber<msgtype>::sem[CANARD_NUM_HANDLERS];
101- #endif
102-
103101template <typename T, typename msgtype>
104102class SubscriberArgCb {
105103public:
0 commit comments