UNPKG

@itwin/core-frontend

Version:
42 lines 2.11 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module Tiles */ import { BeTimePoint } from "@itwin/core-bentley"; import { IModelApp } from "../IModelApp"; /** A marker associated with a [[Tile]] to track usage of that tile by any number of [[TileUser]]s. * The marker tracks: * - the set of [[TileUser]]s by which the tile is in use for some purpose (displayed, preloaded, requested, selected for shadow map, etc); and * - the most recent time at which any tile user declared its use of the tile. * The marker is used to allow tiles to be discarded after they become disused by any tile user, via [[Tile.prune]]. * @see [[Tile.usageMarker]]. * @public * @extensions */ export class TileUsageMarker { _timePoint = BeTimePoint.now(); /** Constructs a usage marker with its timepoint set to the current time and its set of [[TileUser]]s empty. */ constructor() { } /** Returns true if this tile is currently in use by no [[TileUser]]s and its timestamp pre-dates `expirationTime`. */ isExpired(expirationTime) { return this.isTimestampExpired(expirationTime) && !this.getIsTileInUse(); } /** Returns true if this tile is currently in use by any [[TileUser]]. */ getIsTileInUse() { return IModelApp.tileAdmin.isTileInUse(this); } /** Returns true if this tile's timestamp pre-dates `expirationTime`, without checking if it is in use. */ isTimestampExpired(expirationTime) { return this._timePoint.before(expirationTime); } /** Updates the timestamp to the specified time and marks the tile as being in use by the specified [[TileUser]]. */ mark(user, time) { this._timePoint = time; IModelApp.tileAdmin.markTileUsed(this, user); } } //# sourceMappingURL=TileUsageMarker.js.map