An implementation of a read-write lock with an internal spin lock.
This class provides an implementation of a read-write lock that uses an internal spin lock and a condition variable to synchronize readers and writers when necessary.
The implementation tries to make faster the scenario when readers come and go but there is no writer. In that case, readers will not pay the price of taking the internal spin lock.
Moreover, this RW lock tries to be fair with writers, giving them the possibility to claim the lock and wait for only the remaining readers, thus preventing starvation.