happy-rusty
    Preparing search index...

    Interface RwLockWriteGuard<T>

    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.

    interface RwLockWriteGuard<T> {
        "[toStringTag]": "RwLockWriteGuard";
        value: T;
        toString(): string;
        unlock(): void;
    }

    Type Parameters

    • T

      The type of the protected value.

    Index

    Properties

    "[toStringTag]": "RwLockWriteGuard"

    The well-known symbol Symbol.toStringTag used by Object.prototype.toString().

    value: T

    The protected value (read-write access).

    const guard = await rwlock.write();
    console.log(guard.value); // Read the value
    guard.value = newValue; // Modify the value
    guard.unlock();

    Methods

    • Custom toString implementation.

      Returns string

      A string representation of the guard.

      const guard = await rwlock.write();
      console.log(guard.toString()); // 'RwLockWriteGuard(42)'
    • Releases the write lock.

      After calling unlock(), the guard should not be used.

      Returns void

      const guard = await rwlock.write();
      try {
      guard.value = newValue;
      } finally {
      guard.unlock();
      }