Langium - v4.4.0
    Preparing search index...

    Interface WorkspaceLock

    Utility service to execute mutually exclusive actions.

    interface WorkspaceLock {
        cancelWrite(): void;
        read<T>(action: () => MaybePromise<T>, priority?: ReadPriority): Promise<T>;
        write(
            action: (token: Cancellation.CancellationToken) => MaybePromise<void>,
        ): Promise<void>;
    }

    Implemented by

    Index
    • Performs a single action, like computing completion results or providing workspace symbols. With ReadPriority.Normal priority (the default), read actions will only be executed after all write actions have finished. They will be executed concurrently if possible.

      If a write action is currently running, the read action will be queued up and executed afterwards. If a new write action is queued up while a read action is waiting, the write action will receive priority and will be handled before the read action.

      With ReadPriority.Immediate priority, the read action is executed right away, concurrently to any running write action. Use this only if the required workspace/document state has already been awaited by other means.

      Note that read actions are not allowed to modify anything in the workspace. Please use write instead. They also cannot be cancelled, independent of their priority, even if a write action is queued up.

      Type Parameters

      • T

      Parameters

      Returns Promise<T>