This repository has been archived by the owner on May 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |