.net - What should I use spin lock or mutex if conflict doesn't occur often -


i'm fixing 1 bug related concurrent access collections in 1 library. library uses mutex(lock) control access multiple threads. locked areas in code contains code should executed quite fast (modifying list/dictionary or read it) spin lock seems match scenario.

but ... in cases lock not necessary because majority of apps uses library single-threaded , important me not slow them down. mine naive benchmark indicates spin lock checks slower resource not used, not trust it.

if advertising function thread safe should provide locking on collection updates.

if not, make sure document fact , leave consumer.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -