如何在 Interleave 中使用 PortMode.OptimizedSingleReissueReceiver? (微软 CCR)

发布于 2024-08-11 13:26:40 字数 1243 浏览 8 评论 0原文

我读过 Microsoft CCR 论坛上关于减少调用 Port.Post() 的开销的帖子 [参考:CCR 中的 PortElement 实例化] 我想知道是否有类似的方法将端口按顺序绑定到其接收器在交错仲裁器中以 OptimizedSingleReissueReceiver 模式使用端口?

我已经实现了以下代码,在 Interleave 上使用此 PortMode:

    // Creates the Receiver 
    Receiver receiver = Arbiter.Receive(true, inputPort, inputPortHandler);
    // Change the port mode before binding the Receiver with the DispatcherQueue
      inputPort.Mode = PortMode.OptimizedSingleReissueReceiver;         

    // Creates the Interleave
    ExclusiveReceiverGroup exclusiveReceiverGroup = new ExclusiveReceiverGroup(receiver);
    Interleave interleave = Arbiter.Interleave(new TeardownReceiverGroup(), 
                                                            exclusiveReceiverGroup, 
                                                            new ConcurrentReceiverGroup());         
    // Activate the Interleave 
    Arbiter.Activate(dispatcherQueue, interleave);

起初,看起来没问题,但是我仍然不时遇到 NullReferenceException(此异常表明端口尚未绑定到接收器)。

有谁知道在 Interleave 内使用 PortMode.OptimizedSingleReissueReceiver 的另一种方法?

I have read a post on the Microsoft CCR forum on reducing the overhead of calls to Port.Post() [ref.: PortElement Instantiation in the CCR] and I was wondering if there is a similar way to bind a port to its receiver in order to use the port in OptimizedSingleReissueReceiver mode in an interleave arbiter?

I have implemented the following code do use this PortMode on an Interleave:

    // Creates the Receiver 
    Receiver receiver = Arbiter.Receive(true, inputPort, inputPortHandler);
    // Change the port mode before binding the Receiver with the DispatcherQueue
      inputPort.Mode = PortMode.OptimizedSingleReissueReceiver;         

    // Creates the Interleave
    ExclusiveReceiverGroup exclusiveReceiverGroup = new ExclusiveReceiverGroup(receiver);
    Interleave interleave = Arbiter.Interleave(new TeardownReceiverGroup(), 
                                                            exclusiveReceiverGroup, 
                                                            new ConcurrentReceiverGroup());         
    // Activate the Interleave 
    Arbiter.Activate(dispatcherQueue, interleave);

At first, it seemed ok, however I still got NullReferenceException from time to time (this exception indicates that the port is not bound to a receiver yet).

Does anyone know another way to use PortMode.OptimizedSingleReissueReceiver inside an Interleave?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文