Skip to content

Commit

Permalink
prepare methods timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciremun committed Feb 4, 2024
1 parent 9759cd9 commit 980a27c
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 150 deletions.
15 changes: 10 additions & 5 deletions freedom/utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Freedom
{
Expand Down Expand Up @@ -198,6 +199,7 @@ public static int PrepareMethods()
{
var assembly = Assembly.GetEntryAssembly();
Type[] classes = assembly.GetTypes();
var tasks = new List<Task>();
int i = 0;
foreach (Type c in classes)
{
Expand All @@ -212,14 +214,17 @@ public static int PrepareMethods()
continue;
if (!VerifyClassMethod(c, m, cm))
continue;
try
{
i += 1;
System.Runtime.CompilerServices.RuntimeHelpers.PrepareMethod(m.MethodHandle);
} catch (Exception) {}
tasks.Add(Task.Run(() => {
try
{
System.Runtime.CompilerServices.RuntimeHelpers.PrepareMethod(m.MethodHandle);
} catch (Exception) {}
}));
i += 1;
}
}
}
Task.WaitAll(tasks.ToArray(), TimeSpan.FromSeconds(10));
return i;
}
}
Expand Down
Loading

0 comments on commit 980a27c

Please sign in to comment.