/** * @since 1.0.0 */ import type * as Effect from "@effect/io/Effect"; import type * as Scope from "@effect/io/Scope"; import type * as STM from "@effect/stm/STM"; /** * @since 1.0.0 * @category symbols */ export declare const TReentrantLockTypeId: unique symbol; /** * @since 1.0.0 * @category symbols */ export type TReentrantLockTypeId = typeof TReentrantLockTypeId; /** * A `TReentrantLock` is a reentrant read/write lock. Multiple readers may all * concurrently acquire read locks. Only one writer is allowed to acquire a * write lock at any given time. Read locks may be upgraded into write locks. A * fiber that has a write lock may acquire other write locks or read locks. * * The two primary methods of this structure are `readLock`, which acquires a * read lock in a scoped context, and `writeLock`, which acquires a write lock * in a scoped context. * * Although located in the STM package, there is no need for locks within STM * transactions. However, this lock can be quite useful in effectful code, to * provide consistent read/write access to mutable state; and being in STM * allows this structure to be composed into more complicated concurrent * structures that are consumed from effectful code. * * @since 1.0.0 * @category models */ export interface TReentrantLock extends TReentrantLock.Proto { } /** * @since 1.0.0 */ export declare namespace TReentrantLock { /** * @since 1.0.0 * @category models */ interface Proto { readonly [TReentrantLockTypeId]: TReentrantLockTypeId; } } /** * Acquires a read lock. The transaction will suspend until no other fiber is * holding a write lock. Succeeds with the number of read locks held by this * fiber. * * @since 1.0.0 * @category mutations */ export declare const acquireRead: (self: TReentrantLock) => STM.STM; /** * Acquires a write lock. The transaction will suspend until no other fibers * are holding read or write locks. Succeeds with the number of write locks * held by this fiber. * * @since 1.0.0 * @category mutations */ export declare const acquireWrite: (self: TReentrantLock) => STM.STM; /** * Retrieves the number of acquired read locks for this fiber. * * @since 1.0.0 * @category mutations */ export declare const fiberReadLocks: (self: TReentrantLock) => STM.STM; /** * Retrieves the number of acquired write locks for this fiber. * * @since 1.0.0 * @category mutations */ export declare const fiberWriteLocks: (self: TReentrantLock) => STM.STM; /** * Just a convenience method for applications that only need reentrant locks, * without needing a distinction between readers / writers. * * See `TReentrantLock.writeLock`. * * @since 1.0.0 * @category mutations */ export declare const lock: (self: TReentrantLock) => Effect.Effect; /** * Determines if any fiber has a read or write lock. * * @since 1.0.0 * @category mutations */ export declare const locked: (self: TReentrantLock) => STM.STM; /** * Makes a new reentrant read/write lock. * * @since 1.0.0 * @category constructors */ export declare const make: STM.STM; /** * Obtains a read lock in a scoped context. * * @since 1.0.0 * @category mutations */ export declare const readLock: (self: TReentrantLock) => Effect.Effect; /** * Retrieves the total number of acquired read locks. * * @since 1.0.0 * @category mutations */ export declare const readLocks: (self: TReentrantLock) => STM.STM; /** * Determines if any fiber has a read lock. * * @since 1.0.0 * @category mutations */ export declare const readLocked: (self: TReentrantLock) => STM.STM; /** * Releases a read lock held by this fiber. Succeeds with the outstanding * number of read locks held by this fiber. * * @since 1.0.0 * @category mutations */ export declare const releaseRead: (self: TReentrantLock) => STM.STM; /** * Releases a write lock held by this fiber. Succeeds with the outstanding * number of write locks held by this fiber. * * @since 1.0.0 * @category mutations */ export declare const releaseWrite: (self: TReentrantLock) => STM.STM; /** * Runs the specified workflow with a lock. * * @since 1.0.0 * @category mutations */ export declare const withLock: { (self: TReentrantLock): (effect: Effect.Effect) => Effect.Effect; (effect: Effect.Effect, self: TReentrantLock): Effect.Effect; }; /** * Runs the specified workflow with a read lock. * * @since 1.0.0 * @category mutations */ export declare const withReadLock: { (self: TReentrantLock): (effect: Effect.Effect) => Effect.Effect; (effect: Effect.Effect, self: TReentrantLock): Effect.Effect; }; /** * Runs the specified workflow with a write lock. * * @since 1.0.0 * @category mutations */ export declare const withWriteLock: { (self: TReentrantLock): (effect: Effect.Effect) => Effect.Effect; (effect: Effect.Effect, self: TReentrantLock): Effect.Effect; }; /** * Obtains a write lock in a scoped context. * * @since 1.0.0 * @category mutations */ export declare const writeLock: (self: TReentrantLock) => Effect.Effect; /** * Determines if a write lock is held by some fiber. * * @since 1.0.0 * @category mutations */ export declare const writeLocked: (self: TReentrantLock) => STM.STM; /** * Computes the number of write locks held by fibers. * * @since 1.0.0 * @category mutations */ export declare const writeLocks: (self: TReentrantLock) => STM.STM; //# sourceMappingURL=TReentrantLock.d.ts.map