Readers-writer lock objects

#include <x/rwlock.H>

x::rwlock lock=x::rwlock::create();

// ...

{
  x::rwlock::base::rlock rlock=lock->readlock();


}

// ...

{
  x::rwlock::base::wlock wlock=lock->writelock();


}

x::rwlock is mostly a reference-counted version of x::rwmutex that also uses reference-counted lock objects. Its readlock() acquires a lock on the underlying r object, and writelock() acquires a lock on the underlying w object. The underlying locks are also reference-counted objects, that can be freely passed around. The locks are released when the last reference to a lock object goes out of scope and an object gets destroyed. x::rwlock implements try_readlock() and try_writelock() which are analogous to a mutex's try_lock(), in a read lock's or a write lock's case.

try_readlock_until(), try_readlock_for(), try_writelock_until(), and try_writelock_for() also return a nullable reference pointer to the acquired lock, which is null if the lock cannot be acquired.