@@ -74,7 +74,14 @@ export declare class ZeroBackpressureSemaphore<T, UncaughtErrorType = Error> {
74
74
/**
75
75
* amountOfUncaughtErrors
76
76
*
77
- * @returns The number of uncaught errors from background jobs, triggered by `startExecution`.
77
+ * Indicates the number of uncaught errors from background jobs triggered by `startExecution`,
78
+ * that are currently stored by the instance.
79
+ * These errors have not yet been extracted using `extractUncaughtErrors`.
80
+ *
81
+ * Knowing the number of uncaught errors allows users to decide whether to process them immediately
82
+ * or wait for further accumulation.
83
+ *
84
+ * @returns The number of uncaught errors from background jobs.
78
85
*/
79
86
get amountOfUncaughtErrors ( ) : number ;
80
87
/**
@@ -127,14 +134,15 @@ export declare class ZeroBackpressureSemaphore<T, UncaughtErrorType = Error> {
127
134
/**
128
135
* waitForAllExecutingJobsToComplete
129
136
*
130
- * This method allows the caller to wait until all currently executing jobs have completed.
131
- * It is useful for ensuring that the application can terminate gracefully, without leaving
132
- * any pending operations.
137
+ * This method allows the caller to wait until all *currently* executing jobs have finished,
138
+ * meaning once all running promises have either resolved or rejected.
139
+ *
140
+ * This is particularly useful in scenarios where you need to ensure that all jobs are completed
141
+ * before proceeding, such as during shutdown processes or between unit tests.
133
142
*
134
- * When this method is called, it returns a promise that resolves once all currently running
135
- * promises have either resolved or rejected. This is particularly useful in scenarios where
136
- * you need to ensure that all tasks are completed before proceeding, such as during shutdown
137
- * processes or between unit tests.
143
+ * Note that the returned promise only awaits jobs that were executed at the time this method
144
+ * was called. Specifically, it awaits all jobs initiated by this instance that had not completed
145
+ * at the time of invocation.
138
146
*
139
147
* @returns A promise that resolves when all currently executing jobs are completed.
140
148
*/
@@ -160,8 +168,8 @@ export declare class ZeroBackpressureSemaphore<T, UncaughtErrorType = Error> {
160
168
* This method can be useful when the system is experiencing high load (as indicated by CPU and/or memory
161
169
* usage metrics), and you want to pause further async operations until an available job slot opens up.
162
170
* However, the same effect can be achieved with `startExecution` alone if the async logic
163
- * (which you intend to delay until availability) is performed *inside the job* rather than as a
164
- * preliminary step. Therefore, `waitForAvailability` is more of a design choice than a necessity.
171
+ * (intended to be delayed until availability) is handled within the job itself rather than as a preliminary
172
+ * step. Therefore, `waitForAvailability` serves as a design choice rather than a strict necessity.
165
173
*
166
174
* @returns A promise that resolves once at least one slot is available.
167
175
*/
0 commit comments