locks example will deadlock on macos, but not Linux
Running command cargo run --example locks on Linux will run through a number of mutex and rwlock tests,
and eventually return to the command line.
After applying #29, the locks example will now compile and run on macos, but will deadlock, and not finish. (Note that changes in PR #29 should not alter Linux behavior) On linux, running the locks example will go through all the mutex and rwlocks examples and return to the prompt without deadlocking.
_I believe, but have not confirmed the macos failure is due to recursive Mutex and RWLock locking. Linux appears to better handle recursive mutexes than macos, at least for the pthread calls. https://en.wikipedia.org/wiki/Reentrant_mutex
In fact!, there is a 10 year old discussion on Stack Overflow how some recursive mutex code works on Linux, FreeBSD and Solaris, but fails to work on MacOS. This is what leads me to believe the recursive locking of the example causes the deadlock on macos.
The macos platform has a special type: NSRecursiveLock https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Multithreading/ThreadSafety/ThreadSafety.html This type is suggested for recursive locking needs. (And is not used in this library, macos pthreads is used)
one solution to fix the example would be to avoid recursive locking on the macos platform
So, this library might work well for you on macos, and you are not doing recursive locking. In the linked wiki article, some notable computer scientists recommend against avoiding recursive locking if possible.