Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
StackGuard.cs
Go to the documentation of this file.
4
6
7internal sealed class StackGuard
8{
10
12 {
14 {
15 return true;
16 }
17 if (_executionStackCount < 1024)
18 {
19 return false;
20 }
22 }
23
24 public void RunOnEmptyStack<T1, T2>(Action<T1, T2> action, T1 arg1, T2 arg2)
25 {
26 RunOnEmptyStackCore(delegate(object s)
27 {
28 (Action<T1, T2>, T1, T2) tuple = ((Action<T1, T2>, T1, T2))s;
29 tuple.Item1(tuple.Item2, tuple.Item3);
30 return (object)null;
31 }, (action, arg1, arg2));
32 }
33
34 public void RunOnEmptyStack<T1, T2, T3>(Action<T1, T2, T3> action, T1 arg1, T2 arg2, T3 arg3)
35 {
36 RunOnEmptyStackCore(delegate(object s)
37 {
38 (Action<T1, T2, T3>, T1, T2, T3) tuple = ((Action<T1, T2, T3>, T1, T2, T3))s;
39 tuple.Item1(tuple.Item2, tuple.Item3, tuple.Item4);
40 return (object)null;
41 }, (action, arg1, arg2, arg3));
42 }
43
44 public R RunOnEmptyStack<T1, T2, R>(Func<T1, T2, R> action, T1 arg1, T2 arg2)
45 {
46 return RunOnEmptyStackCore(delegate(object s)
47 {
48 (Func<T1, T2, R>, T1, T2) tuple = ((Func<T1, T2, R>, T1, T2))s;
49 return tuple.Item1(tuple.Item2, tuple.Item3);
50 }, (action, arg1, arg2));
51 }
52
53 public R RunOnEmptyStack<T1, T2, T3, R>(Func<T1, T2, T3, R> action, T1 arg1, T2 arg2, T3 arg3)
54 {
55 return RunOnEmptyStackCore(delegate(object s)
56 {
57 (Func<T1, T2, T3, R>, T1, T2, T3) tuple = ((Func<T1, T2, T3, R>, T1, T2, T3))s;
58 return tuple.Item1(tuple.Item2, tuple.Item3, tuple.Item4);
59 }, (action, arg1, arg2, arg3));
60 }
61
62 private R RunOnEmptyStackCore<R>(Func<object, R> action, object state)
63 {
65 try
66 {
68 if (!task.IsCompleted)
69 {
70 ((IAsyncResult)task).AsyncWaitHandle.WaitOne();
71 }
72 return task.GetAwaiter().GetResult();
73 }
74 finally
75 {
77 }
78 }
79}
void RunOnEmptyStack< T1, T2 >(Action< T1, T2 > action, T1 arg1, T2 arg2)
Definition StackGuard.cs:24
R RunOnEmptyStackCore< R >(Func< object, R > action, object state)
Definition StackGuard.cs:62
R RunOnEmptyStack< T1, T2, R >(Func< T1, T2, R > action, T1 arg1, T2 arg2)
Definition StackGuard.cs:44
void RunOnEmptyStack< T1, T2, T3 >(Action< T1, T2, T3 > action, T1 arg1, T2 arg2, T3 arg3)
Definition StackGuard.cs:34
R RunOnEmptyStack< T1, T2, T3, R >(Func< T1, T2, T3, R > action, T1 arg1, T2 arg2, T3 arg3)
Definition StackGuard.cs:53
static new TaskFactory< TResult > Factory
Definition Task.cs:56