Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Release() [2/2]

int System.Threading.SemaphoreSlim.Release ( int releaseCount)
inline

Definition at line 398 of file SemaphoreSlim.cs.

399 {
400 CheckDispose();
401 if (releaseCount < 1)
402 {
403 throw new ArgumentOutOfRangeException("releaseCount", releaseCount, SR.SemaphoreSlim_Release_CountWrong);
404 }
405 int num;
407 {
408 int currentCount = m_currentCount;
409 num = currentCount;
410 if (m_maxCount - currentCount < releaseCount)
411 {
412 throw new SemaphoreFullException();
413 }
414 currentCount += releaseCount;
415 int waitCount = m_waitCount;
416 int num2 = Math.Min(currentCount, waitCount) - m_countOfWaitersPulsedToWake;
417 if (num2 > 0)
418 {
419 if (num2 > releaseCount)
420 {
421 num2 = releaseCount;
422 }
424 for (int i = 0; i < num2; i++)
425 {
426 Monitor.Pulse(m_lockObjAndDisposed);
427 }
428 }
429 if (m_asyncHead != null)
430 {
431 int num3 = currentCount - waitCount;
432 while (num3 > 0 && m_asyncHead != null)
433 {
434 currentCount--;
435 num3--;
436 TaskNode asyncHead = m_asyncHead;
437 RemoveAsyncWaiter(asyncHead);
438 asyncHead.TrySetResult(result: true);
439 }
440 }
441 m_currentCount = currentCount;
442 if (m_waitHandle != null && num == 0 && currentCount > 0)
443 {
445 }
446 }
447 return num;
448 }
bool RemoveAsyncWaiter(TaskNode task)
readonly StrongBox< bool > m_lockObjAndDisposed
volatile ManualResetEvent m_waitHandle

References System.Threading.SemaphoreSlim.CheckDispose(), System.Threading.SemaphoreSlim.m_asyncHead, System.Threading.SemaphoreSlim.m_countOfWaitersPulsedToWake, System.Threading.SemaphoreSlim.m_currentCount, System.Threading.SemaphoreSlim.m_lockObjAndDisposed, System.Threading.SemaphoreSlim.m_maxCount, System.Threading.SemaphoreSlim.m_waitCount, System.Threading.SemaphoreSlim.m_waitHandle, System.Math.Min(), System.Threading.Monitor.Pulse(), System.Threading.SemaphoreSlim.RemoveAsyncWaiter(), System.SR.SemaphoreSlim_Release_CountWrong, System.Threading.EventWaitHandle.Set(), and System.Threading.Tasks.Task< TResult >.TrySetResult().