A guard that provides shared read access to the RwLock-protected value.
Multiple read guards can exist simultaneously, but no write guards can be acquired while any read guard is held.
The type of the protected value.
Readonly
The well-known symbol Symbol.toStringTag used by Object.prototype.toString().
Symbol.toStringTag
Object.prototype.toString()
The protected value (read-only access).
const guard = await rwlock.read();console.log(guard.value); // Read the valueguard.unlock(); Copy
const guard = await rwlock.read();console.log(guard.value); // Read the valueguard.unlock();
Custom toString implementation.
toString
A string representation of the guard.
const guard = await rwlock.read();console.log(guard.toString()); // 'RwLockReadGuard(42)' Copy
const guard = await rwlock.read();console.log(guard.toString()); // 'RwLockReadGuard(42)'
Releases the read lock.
After calling unlock(), the guard should not be used.
unlock()
const guard = await rwlock.read();try { console.log(guard.value);} finally { guard.unlock();} Copy
const guard = await rwlock.read();try { console.log(guard.value);} finally { guard.unlock();}
A guard that provides shared read access to the RwLock-protected value.
Multiple read guards can exist simultaneously, but no write guards can be acquired while any read guard is held.