69
70
active(consumer: string): IDisposable {
72
>
const current = this._consumers.get(consumer) ?? 0;
73
>
this._consumers.set(consumer, current + 1);
74
>
this._totalCount++;
75
>
76
>
this._logService.debug(`ServerLifetime: consumer '${consumer}' active (total: ${this._totalCount})`);
77
>
78
>
if (wasEmpty) {
79
>
this._cancelShutdown();
80
>
}
81
>
82
>
let disposed = false;
83
>
return toDisposable(() => {
84
>
if (disposed) {
85
return;
86
}
88
>
89
>
const count = this._consumers.get(consumer);
90
>
if (count !== undefined) {
91
>
if (count <= 1) {
92
>
this._consumers.delete(consumer);
93
>
} else {
94
this._consumers.set(consumer, count - 1);
95
}
97
>
this._totalCount--;
98
>
99
>
this._logService.debug(`ServerLifetime: consumer '${consumer}' inactive (total: ${this._totalCount})`);
100
>
101
>
if (this._totalCount === 0 && this._options.enableAutoShutdown) {
102
this._scheduleShutdown(false);
103
}
105
>
}
106
107
delay(): void {