Esempio n. 1
0
        /*
         * This is the central method of the whole Dataflow engine as it executes the patches.
         *
         * A breath first search over the entire graph is done, starting from the rootSet.
         * All patches that have no connected inlets are part of the rootSet.
         *
         * The algorith is the follow
         *
         * 1) push all elements from the root set into the execution queue
         *
         * 2) dequeue a patch from the execution queue
         * 3) if execution criteria is met execute it *1
         * 4) propagate the values of all changed outlets and add the receiving patches to the discovered set *2 *3
         * 5) goto to step 2 if the execution queue is not empty
         * 6) move all elements from the discovered set to the execution queue
         * 7) goto step 2 if the execution queue is not empty
         * 8) finish the frame
         *
         * *1 right now the only criteria is 'execute allways'
         * *2 outlet values propagation and patch enqueuing are done from first to last outlet.
         * *3 order of discovery is maintained during execution.
         */
        public void StepFrame()
        {
            LinkedList <IPatchContainer>       executionQueue = new LinkedList <IPatchContainer> ();
            HashedLinkedList <IPatchContainer> discoveredSet  = new HashedLinkedList <IPatchContainer> ();

            executionQueue.AddAll(this.rootSet);

            do
            {
                while (executionQueue.Count > 0)
                {
                    IPatchContainer patch = executionQueue.RemoveFirst();
                    patch.ExecutePatch();
                    foreach (IOutlet outlet in patch.Outlets)
                    {
                        outlet.PropagateChanges(discoveredSet);
                    }
                }
                if (discoveredSet.Count > 0)
                {
                    executionQueue.AddAll(discoveredSet);
                    discoveredSet.Clear();
                }
            } while (executionQueue.Count > 0);
        }
Esempio n. 2
0
 public void Reconfigure(IEnumerable <RendezvousEndpoint> newConfiguration)
 {
     configurationStorage.Update(new RendezvousClusterConfiguration {
         Cluster = newConfiguration
     });
     lock (@lock)
     {
         config.Clear();
         config.AddAll(configurationStorage.Read().Cluster);
     }
 }
Esempio n. 3
0
        public void Main()
        {
            // Construct hashed array list using collection initializer
            var list = new HashedLinkedList <int> {
                2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59
            };

            // Chose from list
            list.Choose();

            var array = new int[list.Count];

            // Copy list to array
            list.CopyTo(array, 0);

            // Add item to the end of list
            list.Add(61);

            // Add range to list
            array = new[] { 67, 71, 73, 79, 83 };
            list.AddRange(array);

            // Check if list contains an item
            list.Contains(list.Choose());

            // Check if list contains all items in enumerable
            list.ContainsRange(array);

            // Count all occuerence of an item
            list.CountDuplicates(list.Choose());

            // Find an item in list
            var itemToFind = list.Last;

            list.Find(ref itemToFind);

            // Return all occurence of an item
            list.FindDuplicates(itemToFind);

            // Remove within range
            list.RemoveIndexRange(0, 3);

            var range = new[] { list.First, list.Last };

            // Remove all items in enumerable from list
            list.RemoveRange(range);

            // Retain all items in enumarable from list
            list.RetainRange(list.ToArray());

            var lastItem = list.Last;

            // Find last index of an item
            list.LastIndexOf(lastItem);

            // Insert at the end of list
            list.InsertLast(100);

            // Insert at the beginning of list
            list.InsertFirst(-100);

            // Reverse list
            list.Reverse();

            // Shuffle list
            list.Shuffle();

            // Sort list
            list.Sort();

            // Check if list is sorted
            var isSorted = list.IsSorted();

            // Print all items in list by indexer
            var index = 0;

            foreach (var item in list)
            {
                Console.WriteLine($"list[{index++}] = {item}");
            }

            // Clear list
            list.Clear();
        }