How to use PortMode.OptimizedSingleReissueReceiver in Interleave? (Microsoft CCR)

I read a post on the Microsoft CCR forum on reducing the overhead of calling Port.Post () calls [ref .: Building a PortElement in 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 the arsenal of alternation?

I implemented the following code that uses this PortMode for 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 looked fine, however from time to time I still get a NullReferenceException (this exception indicates that the port is not yet connected to the receiver).

Does anyone know a different way to use PortMode.OptimizedSingleReissueReceiver inside Interleave?

+3

Source: https://habr.com/ru/post/1723239/


All Articles