mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-13 19:54:39 +00:00
Trap attempts to register more than one message handler at a time.
This commit is contained in:
parent
47a3ffb15a
commit
850c847bbf
@ -29,6 +29,8 @@
|
||||
|
||||
#include "utility.hpp"
|
||||
|
||||
#include "ch.h"
|
||||
|
||||
class Message {
|
||||
public:
|
||||
static constexpr size_t MAX_SIZE = 276;
|
||||
@ -251,6 +253,9 @@ public:
|
||||
using MessageHandler = std::function<void(Message* const p)>;
|
||||
|
||||
void register_handler(const Message::ID id, MessageHandler&& handler) {
|
||||
if( map_[toUType(id)] != nullptr ) {
|
||||
chDbgPanic("MsgDblReg");
|
||||
}
|
||||
map_[toUType(id)] = std::move(handler);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user