terraria-cpp2il-methodrecon v1.4.4.9
Terraria mobile dump, with reconstructed method body. Dump with CallAnalysis: https://infinitynichto.github.io/terraria-cpp2il
Loading...
Searching...
No Matches
SemaphoreSlim.cs
Go to the documentation of this file.
1using System;
7
8namespace System.Threading
9{
10 // Token: 0x020001DE RID: 478
11 [DebuggerDisplay("Current Count = {m_currentCount}")]
12 [ComVisible(false)]
14 {
15 // Token: 0x1700019D RID: 413
16 // (get) Token: 0x06001140 RID: 4416 RVA: 0x000246B8 File Offset: 0x000228B8
17 public int CurrentCount
18 {
19 get
20 {
21 return this.m_currentCount;
22 }
23 }
24
25 // Token: 0x06001141 RID: 4417 RVA: 0x000246CC File Offset: 0x000228CC
27 {
28 }
29
30 // Token: 0x06001142 RID: 4418 RVA: 0x000246DC File Offset: 0x000228DC
31 public SemaphoreSlim(int initialCount, int maxCount)
32 {
33 this.m_maxCount = maxCount;
35 }
36
37 // Token: 0x06001143 RID: 4419 RVA: 0x00024714 File Offset: 0x00022914
38 public void Wait()
39 {
40 }
41
42 // Token: 0x06001144 RID: 4420 RVA: 0x00024724 File Offset: 0x00022924
43 public bool Wait(int millisecondsTimeout)
44 {
45 bool flag;
46 return flag;
47 }
48
49 // Token: 0x06001145 RID: 4421 RVA: 0x00024734 File Offset: 0x00022934
50 public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken)
51 {
52 int num2;
53 for (;;)
54 {
55 int num = 1;
56 this.CheckDispose();
57 if (millisecondsTimeout != 0)
58 {
60 }
61 if (this.m_currentCount == 0)
62 {
63 }
64 if (num == 0)
65 {
66 }
67 if (this.m_currentCount == 0)
68 {
69 break;
70 }
71 Monitor.Enter(this.m_lockObj, num2 != 0);
72 if (num != 0)
73 {
74 int waitCount = this.m_waitCount;
75 this.m_waitCount = num;
76 }
78 if (asyncHead != null)
79 {
80 Task<bool> task = this.WaitAsync(millisecondsTimeout, cancellationToken);
81 }
82 if (this.m_currentCount != 0)
83 {
84 goto Block_4;
85 }
86 }
87 num2 = 20;
88 bool flag;
89 return flag;
90 Block_4:
91 if (false)
92 {
97 bool flag2;
98 return flag2;
99 }
100 throw new OutOfMemoryException();
101 }
102
103 // Token: 0x06001146 RID: 4422 RVA: 0x0002483C File Offset: 0x00022A3C
104 private bool WaitUntilCountOrTimeout(int millisecondsTimeout, uint startTime, CancellationToken cancellationToken)
105 {
106 if (this.m_currentCount == 0)
107 {
109 object lockObj = this.m_lockObj;
110 long num = 0L;
111 bool flag = Monitor.Wait(lockObj, millisecondsTimeout, num != 0L);
112 return;
113 }
114 }
115
116 // Token: 0x06001147 RID: 4423 RVA: 0x0000207A File Offset: 0x0000027A
118 {
119 throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
120 }
121
122 // Token: 0x06001148 RID: 4424 RVA: 0x00024874 File Offset: 0x00022A74
123 public Task<bool> WaitAsync(int millisecondsTimeout, CancellationToken cancellationToken)
124 {
125 this.CheckDispose();
126 if (cancellationToken != null)
127 {
128 return Task.FromCancellation(cancellationToken);
129 }
130 object lockObj = this.m_lockObj;
131 int currentCount = this.m_currentCount;
132 int currentCount2 = this.m_currentCount;
133 ManualResetEvent waitHandle = this.m_waitHandle;
134 if (waitHandle != null && this.m_currentCount == 0)
135 {
136 bool flag = this.m_waitHandle.Reset();
137 }
138 long num = 0L;
139 if (num == 0L && waitHandle != null)
140 {
141 while (num == 0L)
142 {
143 }
145 return task;
146 }
147 throw new OutOfMemoryException();
148 }
149
150 // Token: 0x06001149 RID: 4425 RVA: 0x000248E4 File Offset: 0x00022AE4
152 {
153 /*
154An exception occurred when decompiling this method (06001149)
155
156ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Threading.SemaphoreSlim/TaskNode System.Threading.SemaphoreSlim::CreateAndAddAsyncWaiter()
157
158 ---> System.Exception: Basic block has to end with unconditional control flow.
159{
160 Block_0:
161 stloc:TaskNode(var_0_0E, ldfld:TaskNode(SemaphoreSlim::m_asyncTail, ldloc:SemaphoreSlim(this)))
162}
163
164 at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1852
165 at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.Optimize(DecompilerContext context, ILBlock method, AutoPropertyProvider autoPropertyProvider, StateMachineKind& stateMachineKind, MethodDef& inlinedMethod, AsyncMethodDebugInfo& asyncInfo, ILAstOptimizationStep abortBeforeStep) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 355
166 at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(IEnumerable`1 parameters, MethodDebugInfoBuilder& builder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 123
167 at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 88
168 --- End of inner exception stack trace ---
169 at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 92
170 at ICSharpCode.Decompiler.Ast.AstBuilder.AddMethodBody(EntityDeclaration methodNode, EntityDeclaration& updatedNode, MethodDef method, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, MethodKind methodKind) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstBuilder.cs:line 1683
171*/;
172 }
173
174 // Token: 0x0600114A RID: 4426 RVA: 0x00024900 File Offset: 0x00022B00
176 {
180 if (next != null)
181 {
184 }
186 if (prev3 != null)
187 {
188 prev3.Next = next;
189 }
194 return true;
195 }
196
197 // Token: 0x0600114B RID: 4427 RVA: 0x00024968 File Offset: 0x00022B68
198 private Task<bool> WaitUntilCountOrTimeoutAsync(SemaphoreSlim.TaskNode asyncWaiter, int millisecondsTimeout, CancellationToken cancellationToken)
199 {
200 /*
201An exception occurred when decompiling this method (0600114B)
202
203ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Threading.Tasks.Task`1<System.Boolean> System.Threading.SemaphoreSlim::WaitUntilCountOrTimeoutAsync(System.Threading.SemaphoreSlim/TaskNode,System.Int32,System.Threading.CancellationToken)
204
205 ---> System.Exception: Basic block has to end with unconditional control flow.
206{
207 IL_0000:
208 brtrue(IL_0000, ldc.i4:bool(1))
209}
210
211 at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1852
212 at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1878
213 at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1878
214 at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1846
215 at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.Optimize(DecompilerContext context, ILBlock method, AutoPropertyProvider autoPropertyProvider, StateMachineKind& stateMachineKind, MethodDef& inlinedMethod, AsyncMethodDebugInfo& asyncInfo, ILAstOptimizationStep abortBeforeStep) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 355
216 at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(IEnumerable`1 parameters, MethodDebugInfoBuilder& builder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 123
217 at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 88
218 --- End of inner exception stack trace ---
219 at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 92
220 at ICSharpCode.Decompiler.Ast.AstBuilder.AddMethodBody(EntityDeclaration methodNode, EntityDeclaration& updatedNode, MethodDef method, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, MethodKind methodKind) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstBuilder.cs:line 1683
221*/;
222 }
223
224 // Token: 0x0600114C RID: 4428 RVA: 0x00024978 File Offset: 0x00022B78
225 public int Release()
226 {
227 return this.Release(1);
228 }
229
230 // Token: 0x0600114D RID: 4429 RVA: 0x0002498C File Offset: 0x00022B8C
231 public int Release(int releaseCount)
232 {
233 this.CheckDispose();
234 Monitor.Enter(this.m_lockObj, releaseCount != 0);
235 int currentCount = this.m_currentCount;
236 int maxCount = this.m_maxCount;
237 int waitCount = this.m_waitCount;
239 Monitor.Pulse(this.m_lockObj);
241 if (asyncHead != null)
242 {
244 if (asyncHead2 != null)
245 {
246 bool flag = this.RemoveAsyncWaiter(asyncHead2);
247 if (asyncHead == null)
248 {
249 }
250 long num = 0L;
252 }
253 }
254 ManualResetEvent waitHandle = this.m_waitHandle;
255 long num2;
256 if (currentCount == 0 && waitHandle != null)
257 {
258 bool flag2 = this.m_waitHandle.Set();
259 num2 = 0L;
260 }
261 if (asyncHead != null)
262 {
263 }
264 if (num2 == 0L)
265 {
266 string resourceString = SemaphoreSlim.GetResourceString("The releaseCount argument must be greater than zero.");
267 }
268 throw new OutOfMemoryException();
269 }
270
271 // Token: 0x0600114E RID: 4430 RVA: 0x00024A50 File Offset: 0x00022C50
273 {
274 long num = 0L;
276 }
277
278 // Token: 0x0600114F RID: 4431 RVA: 0x00024A68 File Offset: 0x00022C68
279 public void Dispose()
280 {
281 GC.SuppressFinalize(this);
282 }
283
284 // Token: 0x06001150 RID: 4432 RVA: 0x00024A7C File Offset: 0x00022C7C
285 protected virtual void Dispose(bool disposing)
286 {
287 if (this.m_waitHandle != null)
288 {
289 ManualResetEvent waitHandle = this.m_waitHandle;
290 }
291 }
292
293 // Token: 0x06001151 RID: 4433 RVA: 0x00024A98 File Offset: 0x00022C98
294 private static void CancellationTokenCanceledEventHandler(object obj)
295 {
296 if (!false)
297 {
298 return;
299 }
300 throw new OutOfMemoryException();
301 }
302
303 // Token: 0x06001152 RID: 4434 RVA: 0x00024AC4 File Offset: 0x00022CC4
304 private void CheckDispose()
305 {
306 /*
307An exception occurred when decompiling this method (06001152)
308
309ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void System.Threading.SemaphoreSlim::CheckDispose()
310
311 ---> System.Exception: Basic block has to end with unconditional control flow.
312{
313 IL_0009:
314 stloc:string(var_0_13, call:string(SemaphoreSlim::GetResourceString, ldstr:string("The semaphore has been disposed.")))
315}
316
317 at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1852
318 at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1878
319 at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1878
320 at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1846
321 at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.Optimize(DecompilerContext context, ILBlock method, AutoPropertyProvider autoPropertyProvider, StateMachineKind& stateMachineKind, MethodDef& inlinedMethod, AsyncMethodDebugInfo& asyncInfo, ILAstOptimizationStep abortBeforeStep) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 355
322 at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(IEnumerable`1 parameters, MethodDebugInfoBuilder& builder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 123
323 at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 88
324 --- End of inner exception stack trace ---
325 at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 92
326 at ICSharpCode.Decompiler.Ast.AstBuilder.AddMethodBody(EntityDeclaration methodNode, EntityDeclaration& updatedNode, MethodDef method, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, MethodKind methodKind) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstBuilder.cs:line 1683
327*/;
328 }
329
330 // Token: 0x06001153 RID: 4435 RVA: 0x00024AE4 File Offset: 0x00022CE4
331 private static string GetResourceString(string str)
332 {
333 string text;
334 return text;
335 }
336
337 // Token: 0x06001154 RID: 4436 RVA: 0x00024AF4 File Offset: 0x00022CF4
338 // Note: this type is marked as 'beforefieldinit'.
340 {
341 }
342
343 // Token: 0x0400094D RID: 2381
344 private int m_currentCount;
345
346 // Token: 0x0400094E RID: 2382
347 private readonly int m_maxCount;
348
349 // Token: 0x0400094F RID: 2383
350 private int m_waitCount;
351
352 // Token: 0x04000950 RID: 2384
353 private object m_lockObj;
354
355 // Token: 0x04000951 RID: 2385
357
358 // Token: 0x04000952 RID: 2386
360
361 // Token: 0x04000953 RID: 2387
363
364 // Token: 0x04000954 RID: 2388
366
367 // Token: 0x04000955 RID: 2389
369
370 // Token: 0x04000956 RID: 2390
372
373 // Token: 0x020001DF RID: 479
374 private sealed class TaskNode : Task<bool>, IThreadPoolWorkItem
375 {
376 // Token: 0x06001155 RID: 4437 RVA: 0x00024B04 File Offset: 0x00022D04
377 internal TaskNode()
378 {
379 }
380
381 // Token: 0x06001156 RID: 4438 RVA: 0x00024B14 File Offset: 0x00022D14
385
386 // Token: 0x06001157 RID: 4439 RVA: 0x00024B24 File Offset: 0x00022D24
390
391 // Token: 0x04000957 RID: 2391
393
394 // Token: 0x04000958 RID: 2392
396 }
397
398 // Token: 0x020001E0 RID: 480
400 [StructLayout(3)]
402 {
403 // Token: 0x06001158 RID: 4440 RVA: 0x00024B34 File Offset: 0x00022D34
404 private void MoveNext()
405 {
406 int num = 1;
408 Task task = this.<>u__2.m_task;
409 this.<>1__state = num;
410 }
411
412 // Token: 0x06001159 RID: 4441 RVA: 0x00024CE8 File Offset: 0x00022EE8
417
418 // Token: 0x04000959 RID: 2393
420
421 // Token: 0x0400095A RID: 2394
423
424 // Token: 0x0400095B RID: 2395
426
427 // Token: 0x0400095C RID: 2396
429
430 // Token: 0x0400095D RID: 2397
432
433 // Token: 0x0400095E RID: 2398
435
436 // Token: 0x0400095F RID: 2399
437 private CancellationTokenSource <cts>5__2;
438
439 // Token: 0x04000960 RID: 2400
441
442 // Token: 0x04000961 RID: 2401
444
445 // Token: 0x04000962 RID: 2402
447 }
448 }
449}
class f__AnonymousType0<< Count > j__TPar
static int TickCount
static void SuppressFinalize(object obj)
Definition GC.cs:116
static bool Wait(object obj, int millisecondsTimeout, bool exitContext)
Definition Monitor.cs:64
static void PulseAll(object obj)
Definition Monitor.cs:94
static void Enter(object obj)
Definition Monitor.cs:11
static void Pulse(object obj)
Definition Monitor.cs:85
static readonly Task< bool > s_trueTask
static string GetResourceString(string str)
SemaphoreSlim(int initialCount)
bool RemoveAsyncWaiter(SemaphoreSlim.TaskNode task)
Task< bool > WaitUntilCountOrTimeoutAsync(SemaphoreSlim.TaskNode asyncWaiter, int millisecondsTimeout, CancellationToken cancellationToken)
static void CancellationTokenCanceledEventHandler(object obj)
SemaphoreSlim.TaskNode CreateAndAddAsyncWaiter()
int Release(int releaseCount)
bool Wait(int millisecondsTimeout)
bool Wait(int millisecondsTimeout, CancellationToken cancellationToken)
bool WaitUntilCountOrTimeout(int millisecondsTimeout, uint startTime, CancellationToken cancellationToken)
Task< bool > WaitAsync(int millisecondsTimeout, CancellationToken cancellationToken)
SemaphoreSlim.TaskNode m_asyncHead
SemaphoreSlim.TaskNode m_asyncTail
static readonly Task< bool > s_falseTask
static Action< object > s_cancellationTokenCanceledEventHandler
virtual void Dispose(bool disposing)
static void QueueWaiterTask(SemaphoreSlim.TaskNode waiterTask)
SemaphoreSlim(int initialCount, int maxCount)
static Task FromCancellation(CancellationToken cancellationToken)
Definition Task.2.cs:1585
static void UnsafeQueueCustomWorkItem(IThreadPoolWorkItem workItem, bool forceGlobal)
Definition ThreadPool.cs:81
void MarkAborted(ThreadAbortException tae)
void SetStateMachine(IAsyncStateMachine stateMachine)
ConfiguredTaskAwaitable< Task >.ConfiguredTaskAwaiter u__1
AsyncTaskMethodBuilder< bool ><> t__builder
ConfiguredTaskAwaitable< bool >.ConfiguredTaskAwaiter u__2