.netmultithreadingspinlockspinwait

Are there any examples in the .Net framework that use spinlock or spinwait?


I had a look at the concurrent collections but they appear to use normal locking underneath the hood. Are there any good examples in the .Net framework that use this locking construct?


I initially looked at ConcurrentDictionary. I saw it was using normal locks but the BlockingCollection class uses SpinWait in its internal methods.


Solution

  • What do you mean by normal locking ? Some kind of lock(object) { ... } construct ?

    If yes, you should look at ConcurrentStack for example, it uses a SpinWait for its job.