TOPLLab / WARDuino

📟 A dynamic WebAssembly VM for embedded systems
https://topllab.github.io/WARDuino/
Mozilla Public License 2.0
80 stars 7 forks source link

Unsubscribe callback handlers when updating a module #173

Open carllocos opened 1 year ago

carllocos commented 1 year ago

When updating a module, we should unsubscribe the callback handlers and this also means that for a MCU we should unsubscribe the service routine.

However, I believe that this may not even be necessary. The reason is that normally when we would update a module. The module should be persisted on the MCU so to survive potential reboots (I already opened an issue for this https://github.com/TOPLLab/WARDuino/issues/121). If we persist a module and we decide to reboot the device, then the ISR get automatically unsubscribed. Meaning that this issue becomes irrelevant. However, I believe as long as we do not have the persisting feature yet, we should manually unsubscribe the ISRs.

What do you think @tolauwae?

tolauwae commented 1 year ago

I agree. The callback system should definitely be reset completely when a new module gets loaded. Except for the event queue imo.

For the persistant module. When that feature is implemented, I still wouldn't reboot the device on a module update because that is pretty slow. So I would still reset the callback system manually on module update.

carllocos commented 1 year ago

Actually, the decision of rebooting or not is dependent on the use case and should come from the developers. As of that, both options should be possible.