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

Method acquireFrame

app/src/DataModel/FrameBuilder.cpp:285–307  ·  view source on GitHub ↗

* @brief Claims a free pool slot, copies @p src + @p ts into it, and returns an aliasing * shared_ptr: no deleter, no per-frame control block. */

Source from the content-addressed store, hash-verified

283 * shared_ptr: no deleter, no per-frame control block.
284 */
285SS_HOT DataModel::TimestampedFramePtr DataModel::FrameBuilder::acquireFrame(
286 const DataModel::Frame& src, const DataModel::TimestampedFrame::SteadyTimePoint& ts)
287{
288 const size_t idx = claimPoolSlot();
289 if (idx == kInvalidSlotIdx) [[unlikely]] {
290 notePoolExhausted();
291 auto heap = std::make_shared<TimestampedFrame>(src, ts);
292 heap->structureGeneration = m_framePoolGeneration;
293 return heap;
294 }
295
296 const auto& slotOwner = m_framePool[idx];
297 auto* slotRaw = slotOwner.get();
298
299 if (preparePooledSlot(slotRaw, src)) [[likely]]
300 copy_frame_values(slotRaw->frame.data, src);
301
302 slotRaw->frame.timestamp = ts;
303 slotRaw->frame.structureGeneration = m_framePoolGeneration;
304 Q_ASSERT(slotRaw->frame.data.groups.size() == src.groups.size());
305
306 return TimestampedFramePtr(slotOwner, &slotRaw->frame);
307}
308
309/**
310 * @brief Convenience overload that timestamps the slot with SteadyClock::now().

Callers

nothing calls this directly

Calls 3

copy_frame_valuesFunction · 0.85
getMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected