pure
    Preparing search index...

    Class RwLock<TRead, TWrite>

    Ensure you have exclusive access in concurrent code

    Only guaranteed if no one else has reference to the inner object

    It can take a second type parameter to specify interface with write methods

    Type Parameters

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    inner: TWrite

    This is public so inner object can be accessed directly ONLY SAFE in sync context

    Methods

    • Acquire a read (shared) lock and call fn with the value. Release the lock when fn returns or throws.

      Type Parameters

      • R

      Parameters

      Returns Promise<R>

    • Acquire a write (exclusive) lock and call fn with the value. Release the lock when fn returns or throws.

      fn takes a setter function as second parameter, which you can use to update the value like x = set(newX)

      Type Parameters

      • R

      Parameters

      Returns Promise<R>