<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Research.Joins;

public class Slide
{
    static void AsyncTest(Action test, string s, int timeout, bool shouldDeadlock)
    {
        var x = Task.Factory.StartNew(test);
        x.Wait(timeout);
        if(x.IsCompleted)
        {
            Console.WriteLine("Completed test: {0} {1}", s, shouldDeadlock ? "- should deadlock !!" : "");
        }
        else
        {
            Console.WriteLine("Killed test: {0} - {1}", s, shouldDeadlock ? "Expected" : "should not deadlock!!");
        }

    }
    static async void Test1()
    {
        Console.WriteLine("Starting test 1");
        var table = Join.Create<Join.LockBased>();
        Synchronous.Channel a; table.Initialize(out a);
        Synchronous.Channel b; table.Initialize(out b);
        table.When(a).And(b).Do(() => Console.WriteLine("Success - Test 1"));
        for (var i = 0; i < 20; i++)
        {
            var r = a.Send();
            await r;
            b();
        }
    }

    static async void Test2()
    {
        Console.WriteLine("Starting test 2");
        var table = Join.Create<Join.LockBased>();
        Synchronous.Channel a; table.Initialize(out a);
        Synchronous.Channel b; table.Initialize(out b);
        table.When(a).And(b).Do(() => Console.WriteLine("Success - Test 2"));
        var r = a.Send();
        b();
        await r;
    }

    public static void Main()
    {<commit_msg>Fiddled with tests so I can understand them better.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Research.Joins;

public class Slide
{
    static void AsyncTest(Func<Task<int>> test, string s, int timeout, bool shouldDeadlock)
    {
        var x = test();
        x.Wait(timeout);

        if(x.IsCompleted)
        {
            Console.WriteLine("Completed test: {0} {1}", s, shouldDeadlock ? "- should deadlock !!" : "");
        }
        else
        {
            Console.WriteLine("Killed test: {0} - {1}", s, shouldDeadlock ? "Expected" : "should not deadlock!!");
        }

    }
    static async Task<int> Test1()
    {
        Console.WriteLine("Starting test 1");
        var table = Join.Create<Join.LockBased>();
        Synchronous.Channel<string> a; table.Initialize(out a);
        Synchronous.Channel<string> b; table.Initialize(out b);
        table.When(a).And(b).Do((_a,_b) => Console.WriteLine("Success - Test 1 - {0} - {1}",_a,_b));
        var r = a.Send("a");
        await r;
        Console.WriteLine("Finished Test 1");
        b("b");
        Console.WriteLine("Finished Test 1");
        return 0;
    }

    static async Task<int> Test2()
    {
        Console.WriteLine("Starting test 2");
        var table = Join.Create<Join.LockBased>();
        Synchronous.Channel a; table.Initialize(out a);
        Synchronous.Channel b; table.Initialize(out b);
        table.When(a).And(b).Do(() => Console.WriteLine("Success - Test 2"));
        var r = a.Send();
        b();
        await r;
        return 1;
    }

    public static void Main()
    {
{'fraction_non_alphanumeric': 0.14396524976729755, 'fraction_numerical': 0.008997828110456097, 'mean_word_length': 2.25, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 17, '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': '5175252', 'n_tokens_mistral': 977, 'n_tokens_neox': 966, 'n_words': 245}