From 147789ec349bf5fe1938f17b65603c7f203ec655 Mon Sep 17 00:00:00 2001 From: Fredi Kats Date: Fri, 1 Mar 2024 15:53:37 +0100 Subject: [PATCH] Add readme --- Readme.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Readme.md diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..722da2c --- /dev/null +++ b/Readme.md @@ -0,0 +1,40 @@ +# Project Mesty + +Mesty is PoC of tooling that try to calculate all possible states of code that executes by multiple threads. + +For example, this code: + +```csharp +public class SampleClass1 +{ + private long _setCount; + private readonly AutoResetEvent _notEmptyEvent = new(false); + + public void Set() + { + long newValue; + newValue = Interlocked.Increment(ref _setCount); + long tempValue = 1; + if (newValue == tempValue) + { + _notEmptyEvent.Set(); + } + } +} +``` + +can be invoked this way: + +```csharp +for (int i = 0; i < 3; i++) + Task.Run(() => classInstance.Set()); +``` + +3 threads will try to execute `Increment` method and possible results of method class for different methods: +``` +1. 1th - 1; 2th - 2; 3th - 3 +2. 1th - 1; 2th - 3; 3th - 2 +3. ... +``` + +Generating all combinations allow us to proof that code has deadlocks or lead to unexpected results.