1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import { Cancelable, CancelableSource, CancelSignal } from "@esfx/cancelable";
|
8 | import { Disposable } from "@esfx/disposable";
|
9 |
|
10 |
|
11 |
|
12 | export declare class CancellationTokenSource implements CancelableSource {
|
13 | private _state;
|
14 | private _token;
|
15 | private _registrations;
|
16 | private _linkingRegistrations;
|
17 | |
18 |
|
19 |
|
20 |
|
21 |
|
22 | constructor(linkedTokens?: Iterable<CancellationToken | Cancelable>);
|
23 | /**
|
24 | * Gets a CancellationToken linked to this source.
|
25 | */
|
26 | get token(): CancellationToken;
|
27 | /**
|
28 | * Cancels the source, evaluating any registered callbacks. If any callback raises an exception,
|
29 | * the exception is propagated to a host specific unhanedle exception mechanism.
|
30 | */
|
31 | cancel(): void;
|
32 | /**
|
33 | * Closes the source, preventing the possibility of future cancellation.
|
34 | */
|
35 | close(): void;
|
36 | /**
|
37 | * Executes the provided callback.
|
38 | *
|
39 | * @param callback The callback to execute.
|
40 | */
|
41 | private _executeCallback;
|
42 | /**
|
43 | * Unlinks the source from any linked tokens.
|
44 | */
|
45 | private _unlink;
|
46 | [Cancelable.cancelSignal](): Cancelable & CancelSignal;
|
47 | [CancelableSource.cancel](): void;
|
48 | }
|
49 | /**
|
50 | * Propagates notifications that operations should be canceled.
|
51 | */
|
52 | export declare class CancellationToken implements Cancelable {
|
53 | |
54 |
|
55 |
|
56 | static readonly none: CancellationToken;
|
57 | |
58 |
|
59 |
|
60 | static readonly canceled: CancellationToken;
|
61 | private _source;
|
62 | |
63 |
|
64 |
|
65 | get cancellationRequested(): boolean;
|
66 | |
67 |
|
68 |
|
69 | get canBeCanceled(): boolean;
|
70 | |
71 |
|
72 |
|
73 | static from(cancelable: CancellationToken | VSCodeCancellationTokenLike | AbortSignalLike | Cancelable): CancellationToken;
|
74 | |
75 |
|
76 |
|
77 |
|
78 | static race(tokens: Iterable<CancellationToken | Cancelable>): CancellationToken;
|
79 | |
80 |
|
81 |
|
82 |
|
83 | static all(tokens: Iterable<CancellationToken | Cancelable>): CancellationToken;
|
84 | |
85 |
|
86 |
|
87 | throwIfCancellationRequested(): void;
|
88 | |
89 |
|
90 |
|
91 |
|
92 |
|
93 | register(callback: () => void): CancellationTokenRegistration;
|
94 | [Cancelable.cancelSignal](): Cancelable & CancelSignal;
|
95 | }
|
96 |
|
97 |
|
98 |
|
99 | export declare class CancelError extends Error {
|
100 | constructor(message?: string);
|
101 | }
|
102 | /**
|
103 | * An object used to unregister a callback registered to a CancellationToken.
|
104 | */
|
105 | export interface CancellationTokenRegistration extends Disposable {
|
106 | |
107 |
|
108 |
|
109 | unregister(): void;
|
110 | }
|
111 |
|
112 |
|
113 |
|
114 | export interface VSCodeCancellationTokenLike {
|
115 | readonly isCancellationRequested: boolean;
|
116 | onCancellationRequested(listener: () => any): {
|
117 | dispose(): any;
|
118 | };
|
119 | }
|
120 |
|
121 |
|
122 |
|
123 | export interface AbortSignalLike {
|
124 | readonly aborted: boolean;
|
125 | addEventListener(type: "abort", callback: () => any): any;
|
126 | }
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 | export declare class CancellationTokenCountdown {
|
133 | private _addedCount;
|
134 | private _signaledCount;
|
135 | private _canBeSignaled;
|
136 | private _source;
|
137 | private _registrations;
|
138 | constructor(iterable?: Iterable<CancellationToken | Cancelable>);
|
139 | /**
|
140 | * Gets the number of tokens added to the countdown.
|
141 | */
|
142 | get addedCount(): number;
|
143 | /**
|
144 | * Gets the number of tokens that have not yet been canceled.
|
145 | */
|
146 | get remainingCount(): number;
|
147 | /**
|
148 | * Gets the CancellationToken for the countdown.
|
149 | */
|
150 | get token(): CancellationToken;
|
151 | /**
|
152 | * Adds a CancellationToken to the countdown.
|
153 | */
|
154 | add(token: CancellationToken | Cancelable): this;
|
155 | private _checkSignalState;
|
156 | }
|