Skip to content

Commit 8da63c9

Browse files
committed
Added some trace messages to PacketManager and HistoryManager. Fixed bug causing PacketManager to refresh twice any time new waveform data showed up, wasting time
1 parent 8c25b20 commit 8da63c9

5 files changed

Lines changed: 25 additions & 11 deletions

File tree

src/ngscopeclient/HistoryManager.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ void HistoryManager::AddHistory(
265265
if(HasHistory(tp))
266266
return;
267267

268+
LogTrace("Adding history for %s\n", tp.PrettyPrint().c_str());
269+
268270
//All good. Generate a new history point and add it
269271
auto pt = make_shared<HistoryPoint>();
270272
m_history.push_back(pt);
@@ -309,10 +311,15 @@ void HistoryManager::AddHistory(
309311
//With multiple trigger groups at different rates, we might have the most recent trigger for a scope
310312
//roll to the start of the history queue. Don't delete that!!
311313
if(point->IsInUse())
314+
{
315+
LogTrace("Not removing %s because it's in use\n", point->m_time.PrettyPrint().c_str());
312316
continue;
317+
}
313318

319+
LogTrace("Removing un-pinned waveform at t=%s (now have %zu points of %d allowed)\n",
320+
point->m_time.PrettyPrint().c_str(), m_history.size(), m_maxDepth);
314321
m_session.RemoveMarkers(point->m_time);
315-
m_session.RemovePackets(point->m_time);
322+
m_session.RemovePackets(point->m_time, false);
316323
m_history.erase(it);
317324
deletedSomething = true;
318325
break;

src/ngscopeclient/PacketManager.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* ngscopeclient *
44
* *
5-
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
5+
* Copyright (c) 2012-2025 Andrew D. Zonenberg and contributors *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -179,13 +179,13 @@ void PacketManager::Update()
179179
if(key == m_cachekey)
180180
return;
181181

182-
LogTrace("Updating\n");
182+
LogTrace("Updating packet manager with new data at %s\n", time.PrettyPrint().c_str());
183183

184184
//If we get here, waveform changed. Update cache key
185185
m_cachekey = key;
186186

187187
//Remove any old history we might have had from this timestamp
188-
RemoveHistoryFrom(time);
188+
RemoveHistoryFrom(time, false);
189189

190190
//Copy the new packets and detach them so the filter doesn't delete them.
191191
//Do the merging now
@@ -307,11 +307,17 @@ void PacketManager::FilterPackets()
307307

308308
/**
309309
@brief Removes all history from the specified timestamp
310+
311+
@param timestamp Time to remove the history from
312+
@param refreshAfter True if we should refresh the list of displayed rows, false to not refresh
313+
(should only be set false in Update())
310314
*/
311-
void PacketManager::RemoveHistoryFrom(TimePoint timestamp)
315+
void PacketManager::RemoveHistoryFrom(TimePoint timestamp, bool refreshAfter)
312316
{
313317
lock_guard<recursive_mutex> lock(m_mutex);
314318

319+
LogTrace("Removing history from %s\n", timestamp.PrettyPrint().c_str());
320+
315321
auto& packets = m_packets[timestamp];
316322
for(auto p : packets)
317323
{
@@ -323,7 +329,8 @@ void PacketManager::RemoveHistoryFrom(TimePoint timestamp)
323329
m_filteredPackets.erase(timestamp);
324330

325331
//update the list of displayed rows so we don't have anything left pointing to stale packets
326-
RefreshRows();
332+
if(refreshAfter)
333+
RefreshRows();
327334
}
328335

329336
void PacketManager::RemoveChildHistoryFrom(Packet* pack)

src/ngscopeclient/PacketManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class PacketManager
156156
virtual ~PacketManager();
157157

158158
void Update();
159-
void RemoveHistoryFrom(TimePoint timestamp);
159+
void RemoveHistoryFrom(TimePoint timestamp, bool refreshAfter = true);
160160

161161
std::recursive_mutex& GetMutex()
162162
{ return m_mutex; }

src/ngscopeclient/Session.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3473,10 +3473,10 @@ shared_ptr<PacketManager> Session::AddPacketFilter(PacketDecoder* filter)
34733473
/**
34743474
@brief Deletes packets from our packet managers for a waveform timestamp
34753475
*/
3476-
void Session::RemovePackets(TimePoint t)
3476+
void Session::RemovePackets(TimePoint t, bool immediateRefresh)
34773477
{
34783478
for(auto it : m_packetmgrs)
3479-
it.second->RemoveHistoryFrom(t);
3479+
it.second->RemoveHistoryFrom(t, immediateRefresh);
34803480
}
34813481

34823482
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

src/ngscopeclient/Session.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* ngscopeclient *
44
* *
5-
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
5+
* Copyright (c) 2012-2025 Andrew D. Zonenberg and contributors *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -535,7 +535,7 @@ class Session
535535
void RemoveMarkers(TimePoint t)
536536
{ m_markers.erase(t); }
537537

538-
void RemovePackets(TimePoint t);
538+
void RemovePackets(TimePoint t, bool immediateRefresh = true);
539539

540540
std::set<FlowGraphNode*> GetAllGraphNodes();
541541

0 commit comments

Comments
 (0)