Ejemplo n.º 1
0
        private T WaitForOp(CollectionOp <T> op)
        {
            bool doneWaiting = false;
            T    val         = default(T);

            var tempoutputBlock = BlockFactory.CreateLambdaBlock <CollectionOp <T> >(x =>
            {
                if (x.OpID == op.OpID)
                {
                    op          = x;
                    val         = x.Value;
                    doneWaiting = true;
                }

                return(true);
            }, "YoloEnumerableOutput");

            outputBlock.AddChild(tempoutputBlock, new Filter <CollectionOp <T> >(null));
            input.Send(op);
            while (!doneWaiting)
            {
            }
            outputBlock.RemoveChild(tempoutputBlock);
            return(val);
        }
Ejemplo n.º 2
0
        public void Add(T item)
        {
            CollectionOp <T> op = new CollectionOp <T>();

            op.OpType = CollectionOpTypes.Add;
            op.Value  = item;
            WaitForOp(op);
        }
Ejemplo n.º 3
0
        public bool Remove(T item)
        {
            CollectionOp <T> op = new CollectionOp <T>();

            op.OpType = CollectionOpTypes.Remove;
            op.Value  = item;
            input.Send(item);
            return(true);
        }
Ejemplo n.º 4
0
 private void SendToOutput(CollectionOp <T> op)
 {
     if (outputConnection.Evaluate(op))
     {
         var newJob = Processor.ObjectPool.GetObject <Job>();
         newJob.Data          = op;
         newJob.JobConnection = outputConnection;
         ProcessorOwner.JobManager.Schedule(newJob);
     }
 }
Ejemplo n.º 5
0
        public YoloEnumerator(AbstractBlock output, BaseInputAdapter inputer)
        {
            CollectionOp <T> enumOp = new CollectionOp <T>();

            enumOp.OpType = CollectionOpTypes.Enumerate;
            parentOutput  = output;
            outputBlock   = BlockFactory.CreateLambdaBlock <CollectionOp <T> >(x =>
            {
                if (x.OpID == enumOp.OpID)
                {
                    EnumOp = x;
                    output.RemoveChild(outputBlock);
                }

                return(true);
            }, "YoloEnumerableOutput");
            output.AddChild(outputBlock, new Filter <CollectionOp <T> >(null));
            inputer.Send(enumOp);
        }