/** @packageDocumentation
 * @module iModels
 */
import { Id64Arg, Id64String } from "@itwin/core-bentley";
import { LockState } from "@itwin/core-common";
import { BriefcaseDb } from "../IModelDb";
import { LockControl } from "../LockControl";
import { SQLiteDb } from "../SQLiteDb";
import { _close, _elementWasCreated, _implementationProhibited, _releaseAllLocks } from "./Symbols";
export declare class ServerBasedLocks implements LockControl {
    readonly [_implementationProhibited]: undefined;
    get isServerBased(): boolean;
    protected readonly lockDb: SQLiteDb;
    protected readonly briefcase: BriefcaseDb;
    private _removeOnCommitListener;
    private _removeOnPushedListener;
    /** The local ID portion of the highest element ID pushed to the server. Elements with this briefcase's ID
     * and a local ID greater than this value are implicitly exclusively locked by us (no server lock required). */
    private _highWaterLocalId;
    private readonly _unsavedChangesTxnId;
    constructor(iModel: BriefcaseDb);
    [_close](): void;
    private getOwners;
    private getLockState;
    /** Read the local ID portion of the iModel's current element ID sequence counter.
     * The native layer writes this value with BeInt64Id::ToString() (decimal by default) but
     * BeInt64Id::FromString() accepts both decimal and "0x"-prefixed hex. BigInt() has the same
     * dual-format behavior, so it is the canonical JS equivalent. Mask to the lower 40 bits. */
    private readCurrentLocalIdSequence;
    /** Persist the current element ID sequence as the new high-water mark. Called after a successful push. */
    private updateHighWaterMark;
    /** Returns true if this element was created by this briefcase after the last push and therefore does not
     * require a server lock. */
    private isNewElement;
    /** Clear the cache of locally held locks.
     * Note: does *not* release locks from server.
     */
    private clearAllLocks;
    /** only for tests */
    getLockCount(state: LockState): number;
    [_releaseAllLocks](): Promise<void>;
    releaseAllLocks(): Promise<void>;
    abandonAllLocks(): Promise<void>;
    private insertLock;
    private insertTxnLockRecord;
    private ownerHoldsExclusiveLock;
    /** Determine whether an the exclusive lock is already held by an element (or one of its owners) */
    holdsExclusiveLock(id: Id64String): boolean;
    holdsSharedLock(id: Id64String): boolean;
    /** if the shared lock on the element supplied is not already held, add it to the set of shared locks required. Then, check owners. */
    private addSharedLock;
    /** add owners (recursively) of an element to a list of required shared locks, if not already held. */
    private addOwnerSharedLocks;
    /** attempt to acquire all necessary locks for a set of elements */
    private acquireAllLocks;
    acquireLocks(arg: {
        shared?: Id64Arg;
        exclusive?: Id64Arg;
    }): Promise<void>;
    private abandonLocks;
    abandonLocksForCurrentUnsavedTxn(): Promise<boolean>;
    abandonLocksForReversedTxn(txnId: Id64String): Promise<boolean>;
    private getAbandonedLocksForTxn;
    acquireLocksForReinstatingTxn(txnId: Id64String): Promise<boolean>;
    holdsNecessaryLocksForReinstatingTxn(txnId: Id64String): boolean;
    clearTxnLockRecords(txnId: Id64String): void;
    /** When an element is newly created in a session, we hold the lock on it implicitly.
     * For elements whose local ID is above the high-water mark this is already handled by [[isNewElement]],
     * so no database write is needed. The only case that does require a write is when the element's ID is
     * at or below the high-water mark (e.g. when re-applying a stash whose elements were created before
     * the last push). */
    [_elementWasCreated](id: Id64String): void;
    private clearDiscoveredLocks;
    /** locks are not necessary during change propagation. */
    private get _locksAreRequired();
    /** throw if locks are currently required and the exclusive lock is not held on the supplied element */
    checkExclusiveLock(id: Id64String, type: string, operation: string): void;
    /** throw if locks are currently required and a shared lock is not held on the supplied element */
    checkSharedLock(id: Id64String, type: string, operation: string): void;
}
export declare function createServerBasedLocks(iModel: BriefcaseDb): LockControl;
//# sourceMappingURL=ServerBasedLocks.d.ts.map