Skip to content
Snippets Groups Projects

automatic unsubscribe from events to reduce risk of UB

Merged Tim Luchterhand requested to merge unsubscribe_events into master
4 files
+ 140
13
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 30
0
//
// Created by tim on 22.03.23.
//
#include "util/SubscribableEvent.hpp"
namespace schedcl {
void SubscriberHandle::dispose() noexcept {
disposed = true;
}
bool SubscriberHandle::isDisposed() const noexcept {
return disposed;
}
void SubscriberHandle::unregisterHandler() {
invokeDeregister();
}
SubscriberHandle::~SubscriberHandle() {
invokeDeregister();
}
void SubscriberHandle::invokeDeregister() {
if (not disposed and eventStatus->isAlive()) {
deregister(id);
}
}
}
\ No newline at end of file
Loading