A guard that provides exclusive write access to the RwLock-protected value.
Only one write guard can exist at a time, and no read guards can be acquired while a write 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-write access).
const guard = await rwlock.write();console.log(guard.value); // Read the valueguard.value = newValue; // Modify the valueguard.unlock(); Copy
const guard = await rwlock.write();console.log(guard.value); // Read the valueguard.value = newValue; // Modify the valueguard.unlock();
Custom toString implementation.
toString
A string representation of the guard.
const guard = await rwlock.write();console.log(guard.toString()); // 'RwLockWriteGuard(42)' Copy
const guard = await rwlock.write();console.log(guard.toString()); // 'RwLockWriteGuard(42)'
Releases the write lock.
After calling unlock(), the guard should not be used.
unlock()
const guard = await rwlock.write();try { guard.value = newValue;} finally { guard.unlock();} Copy
const guard = await rwlock.write();try { guard.value = newValue;} finally { guard.unlock();}
A guard that provides exclusive write access to the RwLock-protected value.
Only one write guard can exist at a time, and no read guards can be acquired while a write guard is held.