<commit_before>﻿namespace SomeOrderThing
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading;
    using System.Threading.Tasks;
    using Messages.Events;
    using Messages.Commands;

    internal class Program
    {
        public static void Main(string[] args)
        {
            var publisher = new TopicBasedPubSub();

            var monitor = new Monitor();
            var printer = new PrintingHandler();
            var cashier = new TaskThreadedHandler<TakePayment>(new Cashier(publisher), "cashier");
            var assMan = new TaskThreadedHandler<PriceOrder>(new AssistantManager(publisher), "assMan");

            var midgetHouse = new TaskThreadedHandler<OrderPlaced>(new MidgetHouse(publisher), "MidgetHouse");

            var random = new Random();
            var cooks = new[]
            {
                new TaskThreadedHandler<CookFood>(new Cook(publisher, "Guybrush Threepwood", random.Next(500, 3000)), "Guybrush Threepwood"),
                new TaskThreadedHandler<CookFood>(new Cook(publisher, "Elaine Marley", random.Next(500, 3000)), "Elaine Marley"),
                new TaskThreadedHandler<CookFood>(new Cook(publisher, "Zombie Pirate LeChuck", random.Next(500, 3000)), "Zombie Pirate LeChuck")
            };

            var dispatcher = new TaskThreadedHandler<CookFood>(
                new MoreFairDispatcher<CookFood>(cooks), "More fair handler");

            var waiter = new Waiter(publisher);

            var list = new List<IMonitorable>();
            list.AddRange(cooks, cashier, assMan, dispatcher, midgetHouse);

            publisher.SubscribeByType(dispatcher);
            publisher.SubscribeByType(assMan);
            publisher.SubscribeByType(cashier);
            publisher.SubscribeByType(printer);
            publisher.SubscribeByType(midgetHouse);

            var cts = new CancellationTokenSource();
            Task.Run(() => MonitorStuff(list, cts.Token));

            list.ForEach(item => item.Start());

            for (var i = 0; i < 20; i++)
            {
                var id = Guid.NewGuid();
                publisher.SubscribeByCorrelationId(id, monitor);
                var order = new TableOrder(id);
                waiter.Handle(order);
            }

            Thread.Sleep(2000);
            publisher.UnsubscribeByType(dispatcher);
            publisher.SubscribeByType(cooks.First());

            Console.ReadLine();

            cts.Cancel();

            list.ForEach(item => item.Dispose());
        }

        private static void MonitorStuff(IEnumerable<IMonitorable> handlers, CancellationToken token)
        {
            while (!token.IsCancellationRequested)
            {
                foreach (var handler in handlers)
                {
                    Console.Write("{0}: {1}, ", handler.Name, handler.Count);
                }

                Console.WriteLine();

                Thread.Sleep(1000);
            }
        }
    }
}
<commit_msg>Pausing before exiting<commit_after>﻿namespace SomeOrderThing
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading;
    using System.Threading.Tasks;
    using Messages.Events;
    using Messages.Commands;

    internal class Program
    {
        public static void Main(string[] args)
        {
            var publisher = new TopicBasedPubSub();

            var monitor = new Monitor();
            var printer = new PrintingHandler();
            var cashier = new TaskThreadedHandler<TakePayment>(new Cashier(publisher), "cashier");
            var assMan = new TaskThreadedHandler<PriceOrder>(new AssistantManager(publisher), "assMan");

            var midgetHouse = new TaskThreadedHandler<OrderPlaced>(new MidgetHouse(publisher), "MidgetHouse");

            var random = new Random();
            var cooks = new[]
            {
                new TaskThreadedHandler<CookFood>(new Cook(publisher, "Guybrush Threepwood", random.Next(500, 3000)), "Guybrush Threepwood"),
                new TaskThreadedHandler<CookFood>(new Cook(publisher, "Elaine Marley", random.Next(500, 3000)), "Elaine Marley"),
                new TaskThreadedHandler<CookFood>(new Cook(publisher, "Zombie Pirate LeChuck", random.Next(500, 3000)), "Zombie Pirate LeChuck")
            };

            var dispatcher = new TaskThreadedHandler<CookFood>(
                new MoreFairDispatcher<CookFood>(cooks), "More fair handler");

            var waiter = new Waiter(publisher);

            var list = new List<IMonitorable>();
            list.AddRange(cooks, cashier, assMan, dispatcher, midgetHouse);

            publisher.SubscribeByType(dispatcher);
            publisher.SubscribeByType(assMan);
            publisher.SubscribeByType(cashier);
            publisher.SubscribeByType(printer);
            publisher.SubscribeByType(midgetHouse);

            var cts = new CancellationTokenSource();
            Task.Run(() => MonitorStuff(list, cts.Token));

            list.ForEach(item => item.Start());

            for (var i = 0; i < 20; i++)
            {
                var id = Guid.NewGuid();
                publisher.SubscribeByCorrelationId(id, monitor);
                var order = new TableOrder(id);
                waiter.Handle(order);
            }

            Thread.Sleep(2000);
            publisher.UnsubscribeByType(dispatcher);
            publisher.SubscribeByType(cooks.First());

            Console.ReadLine();

            cts.Cancel();

            list.ForEach(item => item.Dispose());

            Console.ReadLine();
        }

        private static void MonitorStuff(IEnumerable<IMonitorable> handlers, CancellationToken token)
        {
            while (!token.IsCancellationRequested)
            {
                foreach (var handler in handlers)
                {
                    Console.Write("{0}: {1}, ", handler.Name, handler.Count);
                }

                Console.WriteLine();

                Thread.Sleep(1000);
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.10112, 'fraction_numerical': 0.01088, 'mean_word_length': 1.891304347826087, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4125953', 'n_tokens_mistral': 1777, 'n_tokens_neox': 1567, 'n_words': 343}