MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / WorkThread

Method WorkThread

lib/mdflib/mdflib/src/writecache.cpp:102–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102void WriteCache::WorkThread() {
103 do {
104 std::unique_lock lock(locker_);
105 sample_event_.wait_for(lock, 10s,
106 [&]() -> bool { return stop_thread_.load(); });
107 if (stop_thread_) {
108 break;
109 }
110 for (auto& [channel_group, sample_queue] : cache_) {
111 if (!sample_queue) {
112 continue;
113 }
114
115 switch (writer_.State()) {
116 case WriteState::Init: {
117 sample_queue->TrimQueue(); // Purge the queue using pre-trig time
118 break;
119 }
120 case WriteState::StartMeas: {
121 if (writer_.IsSavePeriodic()) {
122 sample_queue->SaveQueue(lock); // Save the contents of the queue to file
123 }
124 break;
125 }
126
127 case WriteState::StopMeas: {
128 sample_queue->CleanQueue(lock);
129 break;
130 }
131
132 default:
133 sample_queue->Reset();
134 break;
135 }
136 }
137 } while (!stop_thread_);
138 {
139 std::unique_lock lock(locker_);
140 for (auto& [channel_group, sample_queue] : cache_) {
141 if (sample_queue) {
142 sample_queue->CleanQueue(lock);
143 }
144 }
145 }
146}
147
148void WriteCache::RecalculateTimeMaster() {
149 for (auto& [data_group, sample_queue] : cache_) {

Callers

nothing calls this directly

Calls 8

wait_forMethod · 0.80
IsSavePeriodicMethod · 0.80
loadMethod · 0.45
StateMethod · 0.45
TrimQueueMethod · 0.45
SaveQueueMethod · 0.45
CleanQueueMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected