Via [WayBack] TMonitor vrs Critical sections revisited. Back then (https://www.delphitools.info/2013/06/06/tmonitor-vs-trtlcriticalsection/), it was found that critic… – Kiriakos Vlahos – Google+ as he re-did the measurements that DelphiTools did before Delphi XE5 came out:
Slim Reader/Writer Lock (SWRL) is even faster than TMonitor:
- CriticalSection 0.035
- TMonitor 0.019
- SWRL 0.012
Of course if you have a speedy lock-free solution, that is always favourable, but few people know how to write lock free data structures or how to find the libraries (despite Julian Bucknall covering quite a few of them in Delphi back in the days).
Related:
- [WayBack] TMonitor vs TRTLCriticalSection – DelphiTools
- Fixed in XE5 by doing a
TSpinWait.SpinCycle
instead ofYieldProcessor
: [WayBack] The Oracle at Delphi: Monitoring the Monitor (the underlying function got introduced back in [Archive.is] SyncObjs.TSpinWait.SpinCycle – XE API Documentation) - [WayBack] Slim Reader/Writer (SRW) Locks (Windows)
–jeroen