correct locking semantics
This commit is contained in:
parent
8221c90e24
commit
eb47f6543f
@ -139,7 +139,9 @@ void ArbitratingUniverse::deleteSourceUniverse(const DATA::data_header& src)
|
||||
return;
|
||||
if (sources_.size() == 1 && hold_last_look_)
|
||||
return;
|
||||
std::unique_lock lk_wctl(lk_ctl);
|
||||
}
|
||||
{
|
||||
std::unique_lock lk_ctl(mtx_control);
|
||||
sources_.erase(src);
|
||||
}
|
||||
doListChangeCallbacks();
|
||||
@ -187,7 +189,6 @@ std::shared_ptr<void> ArbitratingUniverse::onSourceListChange(std::function<void
|
||||
*/
|
||||
void ArbitratingUniverse::doListChangeCallbacks()
|
||||
{
|
||||
std::shared_lock lk_ctl(mtx_control);
|
||||
for (auto it = cb_sourceListChange.begin(); it != cb_sourceListChange.end();)
|
||||
{
|
||||
if (auto sp = it->lock())
|
||||
@ -197,7 +198,7 @@ void ArbitratingUniverse::doListChangeCallbacks()
|
||||
}
|
||||
else
|
||||
{ // or remove the callback
|
||||
std::unique_lock lk_wctl(lk_ctl);
|
||||
std::unique_lock lk_ctl(mtx_control);
|
||||
it = cb_sourceListChange.erase(it);
|
||||
}
|
||||
}
|
||||
|
@ -95,25 +95,27 @@ bool Universe::isSyncronized()
|
||||
*/
|
||||
void Universe::synchronize(uint8_t sequence_number)
|
||||
{
|
||||
std::shared_lock lk_ctl(mtx_control);
|
||||
if (!sync_data_)
|
||||
return;
|
||||
|
||||
/// > \cite sACN 6.7.2 Sequence Numbering
|
||||
/// >
|
||||
/// > Having first received a packet with sequence number A,
|
||||
/// > a second packet with sequence number B arrives.
|
||||
/// > If, using signed 8-bit binary arithmetic, B - A
|
||||
/// > is less than or equal to 0, but greater than -20,
|
||||
/// > then the packet containing sequence number B shall be deemed out of
|
||||
/// > sequence and discarded.
|
||||
auto a = sync_sequence_;
|
||||
auto b = sequence_number;
|
||||
int8_t dif = b - a;
|
||||
int8_t dif;
|
||||
{
|
||||
std::shared_lock lk_ctl(mtx_control);
|
||||
/// > \cite sACN 6.7.2 Sequence Numbering
|
||||
/// >
|
||||
/// > Having first received a packet with sequence number A,
|
||||
/// > a second packet with sequence number B arrives.
|
||||
/// > If, using signed 8-bit binary arithmetic, B - A
|
||||
/// > is less than or equal to 0, but greater than -20,
|
||||
/// > then the packet containing sequence number B shall be deemed out of
|
||||
/// > sequence and discarded.
|
||||
auto a = sync_sequence_;
|
||||
auto b = sequence_number;
|
||||
dif = b - a;
|
||||
}
|
||||
if (dif <= 0 && dif > -20)
|
||||
return;
|
||||
{
|
||||
std::unique_lock lk_wctl(lk_ctl);
|
||||
std::unique_lock lk_ctl(mtx_control);
|
||||
sync_sequence_ = sequence_number;
|
||||
}
|
||||
DMX::Universe::setData(*sync_data_);
|
||||
|
Loading…
Reference in New Issue
Block a user