1 | import { Disposable, DisposableCollection } from './disposable';
|
2 | import { Emitter, Event } from './event';
|
3 | import { MaybePromise } from './types';
|
4 | export interface Reference<T> extends Disposable {
|
5 | readonly object: T;
|
6 | }
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | export declare abstract class AbstractReferenceCollection<K, V extends Disposable> implements Disposable {
|
52 | protected readonly _keys: Map<string, K>;
|
53 | protected readonly _values: Map<string, V>;
|
54 | protected readonly references: Map<string, DisposableCollection>;
|
55 | protected readonly onDidCreateEmitter: Emitter<V>;
|
56 | readonly onDidCreate: Event<V>;
|
57 | protected readonly onWillDisposeEmitter: Emitter<V>;
|
58 | readonly onWillDispose: Event<V>;
|
59 | protected readonly toDispose: DisposableCollection;
|
60 | constructor();
|
61 | dispose(): void;
|
62 | clear(): void;
|
63 | has(args: K): boolean;
|
64 | keys(): K[];
|
65 | values(): V[];
|
66 | get(args: K): V | undefined;
|
67 | abstract acquire(args: K): MaybePromise<Reference<V>>;
|
68 | protected doAcquire(key: string, object: V): Reference<V>;
|
69 | protected toKey(args: K): string;
|
70 | protected createReferences(key: string, value: V): DisposableCollection;
|
71 | }
|
72 | /**
|
73 | * Asynchronous implementation of AbstractReferenceCollection that requires
|
74 | * the client to provide a value factory, used to service the acquire()
|
75 | * function. That factory may return a Promise if the value cannot be
|
76 | * created immediately.
|
77 | */
|
78 | export declare class ReferenceCollection<K, V extends Disposable> extends AbstractReferenceCollection<K, V> {
|
79 | protected readonly factory: (key: K) => MaybePromise<V>;
|
80 | constructor(factory: (key: K) => MaybePromise<V>);
|
81 | acquire(args: K): Promise<Reference<V>>;
|
82 | protected readonly pendingValues: Map<string, MaybePromise<V>>;
|
83 | protected getOrCreateValue(key: string, args: K): Promise<V>;
|
84 | }
|
85 | /**
|
86 | * Synchronous implementation of AbstractReferenceCollection that requires
|
87 | * the client to provide a value factory, used to service the acquire()
|
88 | * function.
|
89 | */
|
90 | export declare class SyncReferenceCollection<K, V extends Disposable> extends AbstractReferenceCollection<K, V> {
|
91 | protected readonly factory: (key: K) => V;
|
92 | constructor(factory: (key: K) => V);
|
93 | acquire(args: K): Reference<V>;
|
94 | protected getOrCreateValue(key: string, args: K): V;
|
95 | }
|
96 | //# sourceMappingURL=reference.d.ts.map |
\ | No newline at end of file |