rename callback list to better indicate the type of callback
This commit is contained in:
parent
6a2d1242be
commit
4745458b87
|
@ -228,18 +228,18 @@ std::shared_ptr<void> Universe::onData(const DataHandler cb)
|
|||
// wrap the callback with a shared pointer
|
||||
auto sp = std::make_shared<DataHandler>(std::move(cb));
|
||||
// add callback to list (as a weak pointer)
|
||||
callbacks_.push_back(sp);
|
||||
cb_dataChange.push_back(sp);
|
||||
// return token that caller must keep throughout it's scope
|
||||
return sp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Universe::notifyCallers
|
||||
* @brief Universe::doDataCallbacks
|
||||
*/
|
||||
void Universe::doDataCallbacks()
|
||||
{
|
||||
for (auto it = callbacks_.begin(); it != callbacks_.end();)
|
||||
for (auto it = cb_dataChange.begin(); it != cb_dataChange.end();)
|
||||
{
|
||||
if (auto sp = it->lock())
|
||||
{ // if the caller is still holding the token
|
||||
|
@ -248,7 +248,7 @@ void Universe::doDataCallbacks()
|
|||
}
|
||||
else
|
||||
{ // or remove the callback
|
||||
it = callbacks_.erase(it);
|
||||
it = cb_dataChange.erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,6 @@ class Universe {
|
|||
DimmerData null_start_data; //!< NULL Start Code data
|
||||
mutable std::mutex null_start_mutex; //!< memory protect Null Start data
|
||||
|
||||
std::vector<std::weak_ptr<DataHandler>> callbacks_; //!< list of calback functions
|
||||
void doDataCallbacks(); //!< execute valid callbacks
|
||||
|
||||
|
||||
|
@ -91,6 +90,7 @@ class Universe {
|
|||
const int rx_timeout_period_;
|
||||
|
||||
uint8_t status_; //!< the operating state of the universe
|
||||
std::vector<std::weak_ptr<DataHandler>> cb_dataChange;
|
||||
};
|
||||
|
||||
} // namespace DMX
|
||||
|
|
Loading…
Reference in New Issue