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

168 views Asked by At

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?

0

There are 0 answers