01ed13532a10f65d0289c64e66cee1b94d5214da
[mono.git] / mono / mini / TestHelpers.cs
1 using System;
2 using System.Threading;
3
4 namespace MonoTests.Helpers {
5
6         public static class FinalizerHelpers {
7                 private static IntPtr aptr;
8
9                 private static unsafe void NoPinActionHelper (int depth, Action act)
10                 {
11                         // Avoid tail calls
12                         int* values = stackalloc int [20];
13                         aptr = new IntPtr (values);
14
15                         if (depth <= 0)
16                                 act ();
17                         else
18                                 NoPinActionHelper (depth - 1, act);
19                 }
20
21                 public static void PerformNoPinAction (Action act)
22                 {
23                         Thread thr = new Thread (() => NoPinActionHelper (1024, act));
24                         thr.Start ();
25                         thr.Join ();
26                 }
27         }
28 }
29