this.finalizes = [];
}
+ public async _(): Promise<this> {
+ return this;
+ }
+
public retain(): void {
++this.retainers;
}
}
}
+export function construct(target: any, property: string, descriptor: PropertyDescriptor) {
+ const old = descriptor.value;
+ descriptor.value = async function(this: Resource): Promise<any> {
+ const parent = target.__proto__;
+ await parent._.call(this); try {
+ return await old.call(this);
+ } catch (error) {
+ parent.finalize.call(this);
+ throw error; }
+ };
+}
+
interface Waitable<Value> {
size: number;
values(): IterableIterator<Value>;