Exemplo n.º 1
0
        public WriteOnceBlock(Func <T, T> cloningFunction,
                              DataflowBlockOptions dataflowBlockOptions)
        {
            if (dataflowBlockOptions == null)
            {
                throw new ArgumentNullException("dataflowBlockOptions");
            }

            this.cloningFunction      = cloningFunction;
            this.dataflowBlockOptions = dataflowBlockOptions;
            this.compHelper           = CompletionHelper.GetNew(dataflowBlockOptions);
            this.messageBox           = new PassingMessageBox <T> (this, messageQueue, compHelper,
                                                                   () => true, _ => BroadcastProcess(), dataflowBlockOptions,
                                                                   canAccept: () => written.TrySet());
            this.outgoing = new BroadcastOutgoingQueue <T> (this, compHelper,
                                                            () => messageQueue.IsCompleted, messageBox.DecreaseCount,
                                                            dataflowBlockOptions, cloningFunction != null);
        }