guillermomuntaner / Burritos

A collection of Swift Property Wrappers (formerly "Property Delegates")
MIT License
1.33k stars 43 forks source link

Improve AtomicWrite performance with pthread_mutex and os_unfair_lock #8

Closed yvbeek closed 2 years ago

yvbeek commented 5 years ago

Use os_unfair_lock if it is available, otherwise fall back to pthread_mutex.

This should give a nice performance boost according to the tests in this article: https://www.cocoawithlove.com/blog/2016/06/02/threads-and-mutexes.html

yvbeek commented 5 years ago

Why is the wrapper called AtomicWrite instead of Atomic? The documentation was referring to Atomic

I hope that I implemented the locks correctly 🙂

We should probably demonstrate that this is actually faster than DispatchQueue and that it doesn't leak or cause any threading issues.