Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
SpinLock.TryEnter fail fast for timeout 0 #6952
Previously the timeout 0 would Interlocked.Add to set the waiters then CAS spin to unset it immediately after; now it exits before trying to set the waiters so skips both.
As timeout zero is tested early, removed the first time check as the next minimum time of 1ms is unlikely to have passed.
Moved the second time check into the spinning
Passes corefx tests
1M iters (single thread, uncontended but locked) for code
bool lockTaken = false; var s = new SpinLock(false); s.Enter(ref lockTaken);
referenced this pull request
Aug 27, 2016
@stephentoub seeing similar effects to the previous for threadpool i.e. not much change or improvements