Wait on the packetqueue condition instead of sleeping. Should help analysis keep up with decoding better and offer faster shutdown.

This commit is contained in:
Isaac Connor committed 2026-02-04 20:44:17 -05:00
1 parent 11a09d5ef9
commit ae42c3c94d
5 files changed
+24 -8

No files matched your search

+5 -4
View File
@@ -34,10 +34,11 @@ void DecoderThread::Run() {
while (!(terminate_ or zm_terminate)) {
if (!monitor_->Decode()) {
if (!(terminate_ or zm_terminate)) {
// We only sleep when Decode returns false because it is an error condition and we will spin like mad if it persists.
Microseconds sleep_for = monitor_->Active() ? Microseconds(ZM_SAMPLE_RATE) : Microseconds(ZM_SUSPENDED_RATE);
Debug(2, "Sleeping for %" PRId64 "us", int64(sleep_for.count()));
std::this_thread::sleep_for(sleep_for);
// We wait on the packetqueue condition variable instead of sleeping.
// This allows us to wake up immediately when new packets are queued.
Microseconds wait_for = monitor_->Active() ? Microseconds(ZM_SAMPLE_RATE) : Microseconds(ZM_SUSPENDED_RATE);
Debug(2, "Waiting for %" PRId64 "us", int64(wait_for.count()));
monitor_->GetPacketQueue()->wait_for(wait_for);
}
}
}