VLink  2.3.0
A high-performance communication middleware
fast_buffer_pool.h 文件参考

Fixed-depth publisher pool that recycles FastBuffer allocations by generation. 更多...

#include <cstddef>
#include <vector>
#include "./fast_buffer.h"
fast_buffer_pool.h 的引用(Include)关系图:

浏览源代码.

类

class  vlink::zerocopy::FastBufferPool
 Owns a fixed set of equally sized allocations and recycles them in round-robin order. 更多...
 

命名空间

 
 

详细描述

Fixed-depth publisher pool that recycles FastBuffer allocations by generation.

A publisher of shared descriptors must neither overwrite an allocation that importers still read nor wait for them. FastBufferPool owns depth allocations of one size and hands out the next one whose readers have all released it. The manager increments that allocation's generation first, so descriptors published earlier for it fail to import as expired instead of observing overwritten bytes. Dead reader processes are purged by identity, so a crashed subscriber never pins a slot.

Call Effect
create(size, depth) Allocates depth uninitialised buffers through the provider
acquire(buffer) Clears buffer, then retains the next reusable slot
clear() Releases the slots; retained buffers keep theirs alive
Publish cycle
vlink::zerocopy::FastBuffer frame;
if (pool.create(frame_size, 4)) {
while (running) {
if (pool.acquire(frame)) {
fill(frame); // map()/unmap() or device work
pub.publish(frame); // shared descriptor when the provider supports it
} // otherwise every slot is still being read: skip this frame
} // dropping frame returns its slot without waiting
}
Choose depth larger than the deepest subscriber queue plus the frames a subscriber retains; slower subscribers then drop expired frames rather than stalling the publisher. One thread drives a pool.