UNPKG

@theia/core

Version:

Theia is a cloud & desktop IDE framework implemented in TypeScript.

67 lines • 2.58 kB
/******************************************************************************** * Copyright (c) 2021 STMicroelectronics and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * This Source Code may also be made available under the following Secondary * Licenses when the conditions for such availability set forth in the Eclipse * Public License v. 2.0 are satisfied: GNU General Public License, version 2 * with the GNU Classpath Exception which is available at * https://www.gnu.org/software/classpath/license.html. * * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 *******************************************************************************/ import { __decorate } from "tslib"; /* eslint-disable @typescript-eslint/no-explicit-any */ import { inject, injectable } from 'inversify'; import { Stopwatch } from './stopwatch.js'; export const BackendStopwatch = Symbol('BackendStopwatch'); /** API path of the stopwatch service that exposes the back-end stopwatch to clients. */ export const stopwatchPath = '/services/stopwatch'; export const BackendStopwatchOptions = Symbol('BackendStopwatchOptions'); /** * Default implementation of the (remote) back-end stopwatch service. */ let DefaultBackendStopwatch = class DefaultBackendStopwatch { constructor() { this.measurements = new Map(); this.idSequence = 0; } start(name, options) { const result = ++this.idSequence; this.measurements.set(result, this.stopwatch.start(name, options)); return result; } stop(measurementToken, message, messageArgs) { const measurement = this.measurements.get(measurementToken); if (measurement) { this.measurements.delete(measurementToken); measurement.log(message, ...messageArgs); } } }; __decorate([ inject(Stopwatch) ], DefaultBackendStopwatch.prototype, "stopwatch", void 0); DefaultBackendStopwatch = __decorate([ injectable() ], DefaultBackendStopwatch); export { DefaultBackendStopwatch }; /** * No-op implementation of the (remote) back-end stopwatch service. */ let NullBackendStopwatch = class NullBackendStopwatch { start() { return Promise.resolve(0); } stop() { return Promise.resolve(); } }; NullBackendStopwatch = __decorate([ injectable() ], NullBackendStopwatch); export { NullBackendStopwatch }; //# sourceMappingURL=measurement-protocol.js.map