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

◆ ContinueTryEnterWithThreadTracking()

void System.Threading.SpinLock.ContinueTryEnterWithThreadTracking ( int millisecondsTimeout,
uint startTime,
ref bool lockTaken )
inlineprivate

Definition at line 217 of file SpinLock.cs.

218 {
219 int currentManagedThreadId = Environment.CurrentManagedThreadId;
220 if (_owner == currentManagedThreadId)
221 {
222 throw new LockRecursionException(SR.SpinLock_TryEnter_LockRecursionException);
223 }
224 SpinWait spinWait = default(SpinWait);
225 while (true)
226 {
227 spinWait.SpinOnce();
228 if (_owner == 0 && CompareExchange(ref _owner, currentManagedThreadId, 0, ref lockTaken) == 0)
229 {
230 break;
231 }
232 switch (millisecondsTimeout)
233 {
234 case -1:
235 continue;
236 case 0:
237 return;
238 }
239 if (spinWait.NextSpinWillYield && TimeoutHelper.UpdateTimeOut(startTime, millisecondsTimeout) <= 0)
240 {
241 return;
242 }
243 }
244 }
static int CompareExchange(ref int location, int value, int comparand, ref bool success)
Definition SpinLock.cs:78

References System.Threading.SpinLock._owner, System.Threading.SpinLock.CompareExchange(), System.Environment.CurrentManagedThreadId, System.millisecondsTimeout, System.Threading.SpinWait.NextSpinWillYield, System.SR.SpinLock_TryEnter_LockRecursionException, System.Threading.SpinWait.SpinOnce(), and System.Threading.TimeoutHelper.UpdateTimeOut().

Referenced by System.Threading.SpinLock.ContinueTryEnter().