Table of Contents

Class ShmCellTransport

Namespace
KernLab.Cell
Assembly
KernLab.Cell.dll

shm 载体(§4 阶梯级 2——环回段+门铃,内核移出数据通路):宿主侧创建段(一段双环, 严格 SPSC——A 环宿主→容器调用域,B 环容器→宿主回执/回调/遥测域),两环均 BlockWriter (调用域不许丢;遥测的丢最旧在容器侧遥测出口内建,不落在环上)。

★ 接入形态:Windows 按名 Open;Unix 匿名段经 bootstrap UDS 传递描述符 (1 段 + 4 门铃,槽位序 = 段, Bell0..Bell3——Tier ShmRing §7 契约)。

★ 通道桥:写侧每帧一次暂存→入环(Tier Write 为拷贝入口,快路径 TryWrite+Signal); 读侧专用泵线程阻塞 Read(门铃高效等待、对端死亡自醒)→管道——异步面由管道原生提供, 同步阻塞线程不占调用方线程池。泵线程为后台线程:收场依赖对端死亡自醒或进程退出。

public sealed class ShmCellTransport : ICellTransport, IAsyncDisposable
Inheritance
ShmCellTransport
Implements
Inherited Members

Constructors

ShmCellTransport(string, int, ShmRingWaitStrategy)

创建形态(宿主 spawn 前调用);Unix 匿名段,跨进程经 bootstrap 描述符传递。

public ShmCellTransport(string name, int capacityBytes = 1048576, ShmRingWaitStrategy waitStrategy = ShmRingWaitStrategy.Hybrid)

Parameters

name string

段名(端点描述符地址段)。

capacityBytes int

单环容量(2 的幂,≥4KB——Tier 契约)。

waitStrategy ShmRingWaitStrategy

本进程读侧等待策略(Tier §7 三档,各进程自选;缺省 hybrid)。

Fields

DefaultCapacityBytes

默认单环容量(2 的幂,≥4KB——Tier 契约)。

public const int DefaultCapacityBytes = 1048576

Field Value

int

Properties

Ring

创建的环(bootstrap 描述符传出来源——1 段 + 4 门铃)。

public ShmRing? Ring { get; }

Property Value

ShmRing

SegmentName

段名(端点描述符地址段)。

public string SegmentName { get; }

Property Value

string

Methods

Attach(string)

接入已创建段(同进程创建方实例直用;跨进程接入归容器侧 bootstrap/按名)。

public static ShmCellTransport Attach(string name)

Parameters

name string

Returns

ShmCellTransport

BindAsync(CellEndpointDescriptor, CancellationToken)

Bind——绑定端点为服务端听点(宿主侧 spawn 前调用;载体限定描述符)。

public ValueTask<ICellTransportListener> BindAsync(CellEndpointDescriptor endpoint, CancellationToken cancellationToken = default)

Parameters

endpoint CellEndpointDescriptor
cancellationToken CancellationToken

Returns

ValueTask<ICellTransportListener>

ConnectAsync(CellEndpointDescriptor, CancellationToken)

Connect——向端点发起连接(容器侧;端点未绑定即失败,绝不静默重试)。

public ValueTask<ICellTransportConnection> ConnectAsync(CellEndpointDescriptor endpoint, CancellationToken cancellationToken = default)

Parameters

endpoint CellEndpointDescriptor
cancellationToken CancellationToken

Returns

ValueTask<ICellTransportConnection>

DisposeAsync()

public ValueTask DisposeAsync()

Returns

ValueTask