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

◆ Release()

void System.Threading.LowLevelLifoSemaphore.Release ( int releaseCount)
inline

Definition at line 249 of file LowLevelLifoSemaphore.cs.

250 {
251 Counts counts = _separated._counts;
252 int num;
253 while (true)
254 {
255 Counts newCounts = counts;
256 newCounts.AddSignalCount((uint)releaseCount);
257 num = (int)(Math.Min(newCounts.SignalCount, (uint)(counts.WaiterCount + counts.SpinnerCount)) - counts.SpinnerCount - counts.CountOfWaitersSignaledToWake);
258 if (num > 0)
259 {
260 if (num > releaseCount)
261 {
262 num = releaseCount;
263 }
264 newCounts.AddUpToMaxCountOfWaitersSignaledToWake((uint)num);
265 }
266 Counts counts2 = _separated._counts.InterlockedCompareExchange(newCounts, counts);
267 if (counts2 == counts)
268 {
269 break;
270 }
271 counts = counts2;
272 }
273 if (num > 0)
274 {
275 ReleaseCore(num);
276 }
277 }
Counts InterlockedCompareExchange(Counts newCounts, Counts oldCounts)

References System.Threading.LowLevelLifoSemaphore.CacheLineSeparatedCounts._counts, System.Threading.LowLevelLifoSemaphore._separated, System.Threading.LowLevelLifoSemaphore.Counts.AddSignalCount(), System.Threading.LowLevelLifoSemaphore.Counts.AddUpToMaxCountOfWaitersSignaledToWake(), System.Threading.LowLevelLifoSemaphore.Counts.CountOfWaitersSignaledToWake, System.Threading.LowLevelLifoSemaphore.Counts.InterlockedCompareExchange(), System.Math.Min(), System.Threading.LowLevelLifoSemaphore.ReleaseCore(), System.Threading.LowLevelLifoSemaphore.Counts.SignalCount, System.Threading.LowLevelLifoSemaphore.Counts.SpinnerCount, and System.Threading.LowLevelLifoSemaphore.Counts.WaiterCount.