UNPKG

@freemework/common

Version:

Common library of the Freemework Project.

31 lines 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FCancellationTokenSourceTimeout = void 0; const f_cancellation_token_source_manual_js_1 = require("./f_cancellation_token_source_manual.js"); class FCancellationTokenSourceTimeout extends f_cancellation_token_source_manual_js_1.FCancellationTokenSourceManual { _timeoutHandler; constructor(timeout) { super(); this._timeoutHandler = setTimeout(() => { if (this._timeoutHandler !== undefined) { delete this._timeoutHandler; } super.cancel(); }, timeout); } cancel() { this.stopTimer(); super.cancel(); } /** * After call this method, the instance behaves is as `FManualCancellationTokenSource` */ stopTimer() { if (this._timeoutHandler !== undefined) { clearTimeout(this._timeoutHandler); delete this._timeoutHandler; } } } exports.FCancellationTokenSourceTimeout = FCancellationTokenSourceTimeout; //# sourceMappingURL=f_cancellation_token_source_timeout.js.map