VLink  2.3.0
A high-performance communication middleware
vlink::FastBufferPluginInterface类 参考abstract

Supplies platform buffers without exposing a vendor runtime to VLink. 更多...

#include <fast_buffer_plugin_interface.h>

vlink::FastBufferPluginInterface 的协作图:

Public 成员函数

virtual uint8_t * map (const zerocopy::FastBuffer::Buffer &buffer, zerocopy::FastBuffer::Access access) noexcept=0
 Begins CPU access and invalidates stale host cache lines when reading. 更多...
 
virtual bool unmap (const zerocopy::FastBuffer::Buffer &buffer, zerocopy::FastBuffer::Access access) noexcept=0
 Ends CPU access and flushes modified host cache lines when writing. 更多...
 
virtual const void * native_handle (const zerocopy::FastBuffer::Buffer &buffer) const noexcept
 Returns a borrowed native resource for integration with the provider's device APIs. 更多...
 
virtual bool import_native (const void *handle, zerocopy::FastBuffer::Buffer &buffer) noexcept
 Retains a provider-native resource without taking the caller's reference. 更多...
 
virtual uint64_t get_protocol_id () const noexcept=0
 Returns the nonzero identity of the descriptor protocol, including its ABI version. 更多...
 
virtual bool create (size_t size, const zerocopy::FastBuffer::Config &config, zerocopy::FastBuffer::Buffer &buffer) noexcept=0
 Allocates an uninitialised buffer in the requested memory domain. 更多...
 
virtual bool release (zerocopy::FastBuffer::Buffer &buffer) noexcept=0
 Closes the SDK resource and clears it on success; the manager has completed local work. 更多...
 
virtual bool synchronize (const zerocopy::FastBuffer::Buffer &buffer) noexcept=0
 Waits until previously submitted work using this reference has completed. 更多...
 
virtual bool copy (const zerocopy::FastBuffer::Buffer &source, const zerocopy::FastBuffer::Buffer &destination) noexcept=0
 Copies between equal-sized buffers and completes the copy before returning. 更多...
 
virtual bool copy_to_host (const zerocopy::FastBuffer::Buffer &source, Bytes &destination) noexcept=0
 Reads the complete payload into an exactly sized host view. 更多...
 
virtual bool copy_from_host (const Bytes &source, const zerocopy::FastBuffer::Buffer &destination) noexcept=0
 Writes a complete host payload and completes the transfer before returning. 更多...
 
virtual size_t get_handle_size (const zerocopy::FastBuffer::Buffer &buffer) const noexcept
 Returns the fixed descriptor byte count for a live reference. 更多...
 
virtual bool export_handle (const zerocopy::FastBuffer::Buffer &buffer, Bytes &descriptor) noexcept
 Exports the native descriptor, stable for this local reference; the manager handles synchronization. 更多...
 
virtual bool import_handle (const Bytes &descriptor, zerocopy::FastBuffer::Buffer &buffer) noexcept
 Validates a native descriptor and acquires one local SDK reference. 更多...
 
virtual bool destroy_handle (const Bytes &descriptor) noexcept
 Removes named operating-system resources of a descriptor whose exporting process has died. 更多...
 

Protected 成员函数

 FastBufferPluginInterface ()=default
 
virtual ~FastBufferPluginInterface ()=default
 

详细描述

Supplies platform buffers without exposing a vendor runtime to VLink.

All methods may run on different host threads; implementations select the resource's device/context. zerocopy::FastBuffer::Buffer addresses are process-local and must never be dereferenced by VLink on the CPU. Handles are plugin-owned allocation or import references, not wire data. Failed create/import calls leave their output empty and release partial resources. Successful calls return one reference, released exactly once by the host. Size and descriptor length remain constant for that reference.

Export is idempotent and creates no unclaimed reference. Publishing is not an import acknowledgement: a descriptor stays importable until the owner reuses or retires the allocation, after which import fails as expired and the message is dropped like a queue overflow. FastBufferManager owns local references and a shared-memory control block per exported allocation with a generation number and a reader table keyed by process identity; the native descriptor travels inside that block. No operation waits for another process, and dead readers or owners are detected by PID plus start time. Providers whose runtime keeps imported allocations alive independently of the exporter still rely on the reader table to know when an allocation may be overwritten. Descriptors identify the host, device and synchronization state as required by the backend. OS handles require real handle transfer; a numeric FD or device address is insufficient.

Published contents are immutable until all readers finish. The manager synchronizes before export; descriptors identify resources and stay stable for each local reference. The manager synchronizes before final release; an allocation is reused only through zerocopy::FastBufferPool once no local holder or live importer references it, and freed only once its reader table is empty. External device work must be completed by its owner before export, host access or release unless the provider explicitly supports waiting for it. CPU cache maintenance is not a device completion fence. A crashed importer is purged on the owner's next reclaim; forced exporter termination invalidates allocations whose SDK requires its survival; imports that attach a new mapping detect the dead owner and call destroy_handle() for named resources the operating system would otherwise keep. Release buffers before manager shutdown.

Implementations use VLINK_PLUGIN_DECLARE(Implementation, 1, 0). The descriptor protocol identity is separate from this interface ABI. Compatible providers may share a protocol; unrelated providers must use different nonzero IDs. No CUDA, image format or operating-system type is required here.

构造及析构函数说明

◆ FastBufferPluginInterface()

vlink::FastBufferPluginInterface::FastBufferPluginInterface ( )
protecteddefault

◆ ~FastBufferPluginInterface()

virtual vlink::FastBufferPluginInterface::~FastBufferPluginInterface ( )
protectedvirtualdefault

成员函数说明

◆ copy()

virtual bool vlink::FastBufferPluginInterface::copy ( const zerocopy::FastBuffer::Buffer &  source,
const zerocopy::FastBuffer::Buffer &  destination 
)
pure virtualnoexcept

Copies between equal-sized buffers and completes the copy before returning.

参数
sourceSource reference; pending writes must be observed.
destinationIndependently allocated destination.
返回
Whether the copy succeeded; cross-device support is implementation-defined.

◆ copy_from_host()

virtual bool vlink::FastBufferPluginInterface::copy_from_host ( const Bytes &  source,
const zerocopy::FastBuffer::Buffer &  destination 
)
pure virtualnoexcept

Writes a complete host payload and completes the transfer before returning.

参数
sourceHost bytes, valid only for the duration of this call.
destinationEqual-sized destination reference.
返回
Whether the synchronous write completed.

◆ copy_to_host()

virtual bool vlink::FastBufferPluginInterface::copy_to_host ( const zerocopy::FastBuffer::Buffer &  source,
Bytes &  destination 
)
pure virtualnoexcept

Reads the complete payload into an exactly sized host view.

参数
sourceSource reference; pending writes must be observed.
destinationWritable host storage; its pointer and size must not be replaced.
返回
Whether the synchronous read completed.

◆ create()

virtual bool vlink::FastBufferPluginInterface::create ( size_t  size,
const zerocopy::FastBuffer::Config &  config,
zerocopy::FastBuffer::Buffer &  buffer 
)
pure virtualnoexcept

Allocates an uninitialised buffer in the requested memory domain.

参数
sizeRequested nonzero byte count.
configRequested memory domain and device.
bufferEmpty output reference; success returns exactly size addressable bytes.
返回
Whether allocation succeeded.

◆ destroy_handle()

virtual bool vlink::FastBufferPluginInterface::destroy_handle ( const Bytes &  descriptor)
inlinevirtualnoexcept

Removes named operating-system resources of a descriptor whose exporting process has died.

参数
descriptorNative descriptor produced by export_handle() in the dead process.
返回
Whether resources were removed; providers whose runtime reclaims them on process exit return false.
注解
Several processes may call this for the same descriptor; tolerate resources that are already gone.

◆ export_handle()

virtual bool vlink::FastBufferPluginInterface::export_handle ( const zerocopy::FastBuffer::Buffer &  buffer,
Bytes &  descriptor 
)
inlinevirtualnoexcept

Exports the native descriptor, stable for this local reference; the manager handles synchronization.

参数
bufferSource reference, retained by the publisher until receivers have imported it.
descriptorExactly sized host view; its pointer and size must not be replaced.
返回
Whether export succeeded.

◆ get_handle_size()

virtual size_t vlink::FastBufferPluginInterface::get_handle_size ( const zerocopy::FastBuffer::Buffer &  buffer) const
inlinevirtualnoexcept

Returns the fixed descriptor byte count for a live reference.

参数
bufferReference to export.
返回
Nonzero descriptor size, or zero when sharing is unsupported.

◆ get_protocol_id()

virtual uint64_t vlink::FastBufferPluginInterface::get_protocol_id ( ) const
pure virtualnoexcept

Returns the nonzero identity of the descriptor protocol, including its ABI version.

返回
Stable protocol ID shared only by interoperable implementations.

◆ import_handle()

virtual bool vlink::FastBufferPluginInterface::import_handle ( const Bytes &  descriptor,
zerocopy::FastBuffer::Buffer &  buffer 
)
inlinevirtualnoexcept

Validates a native descriptor and acquires one local SDK reference.

参数
descriptorUntrusted wire bytes; the input storage is not retained.
bufferEmpty output reference with an address valid in the importing process.
返回
Whether the protocol, host, device, allocation and synchronization are usable.

◆ import_native()

virtual bool vlink::FastBufferPluginInterface::import_native ( const void *  handle,
zerocopy::FastBuffer::Buffer &  buffer 
)
inlinevirtualnoexcept

Retains a provider-native resource without taking the caller's reference.

参数
handleProvider-defined native object.
bufferEmpty output reference; failure leaves it empty.
返回
Whether import succeeded; unsupported operations return false.

◆ map()

virtual uint8_t* vlink::FastBufferPluginInterface::map ( const zerocopy::FastBuffer::Buffer &  buffer,
zerocopy::FastBuffer::Access  access 
)
pure virtualnoexcept

Begins CPU access and invalidates stale host cache lines when reading.

参数
bufferReference to map.
accessCPU access direction.
返回
Host address, or nullptr when unsupported or failed.

◆ native_handle()

virtual const void* vlink::FastBufferPluginInterface::native_handle ( const zerocopy::FastBuffer::Buffer &  buffer) const
inlinevirtualnoexcept

Returns a borrowed native resource for integration with the provider's device APIs.

参数
bufferLive reference.
返回
Provider-defined native object, or nullptr when unavailable.

◆ release()

virtual bool vlink::FastBufferPluginInterface::release ( zerocopy::FastBuffer::Buffer &  buffer)
pure virtualnoexcept

Closes the SDK resource and clears it on success; the manager has completed local work.

参数
bufferLive reference to release; implementations report runtime failures in their logs.
返回
Whether the SDK reference was closed. Failure preserves the reference and its buffer.

◆ synchronize()

virtual bool vlink::FastBufferPluginInterface::synchronize ( const zerocopy::FastBuffer::Buffer &  buffer)
pure virtualnoexcept

Waits until previously submitted work using this reference has completed.

参数
bufferLive reference whose device/context is selected by the plugin.
返回
Whether synchronization succeeded.

◆ unmap()

virtual bool vlink::FastBufferPluginInterface::unmap ( const zerocopy::FastBuffer::Buffer &  buffer,
zerocopy::FastBuffer::Access  access 
)
pure virtualnoexcept

Ends CPU access and flushes modified host cache lines when writing.

参数
bufferPreviously mapped reference.
accessMatching CPU access direction.
返回
Whether the operation succeeded; unsupported operations return false.

该类的文档由以下文件生成: