Skip to content

Commit 07fd91a

Browse files
committed
Bump version to v3.0.3: Docs and README improvements
1 parent c137480 commit 07fd91a

7 files changed

+52
-31
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h3 align="middle">Zero Backpressure Semaphore Typescript</h2>
1+
<h2 align="middle">Zero Backpressure Semaphore Typescript</h2>
22

33
The `ZeroBackpressureSemaphore` class implements a semaphore for Node.js projects, allowing users to limit the number of concurrently executing jobs.
44
This implementation does not queue pending jobs, thereby eliminating backpressure. As a result, users have better control over memory footprint, which enhances performance by reducing garbage-collector overhead.
@@ -13,8 +13,8 @@ Each use case necessitates distinct handling capabilities, which will be discuss
1313

1414
- __Backpressure Control__: Ideal for job workers and background services. Concurrency control alone isn't sufficient to ensure stability and performance if backpressure control is overlooked. Without backpressure control, the heap can become overloaded, resulting in space complexity of O(*semaphore-slots* + *pending-jobs*) instead of O(*semaphore-slots*).
1515
- __Graceful Termination__: Await the completion of all currently executing jobs via the `waitForAllExecutingJobsToComplete` method.
16-
- __High Efficiency__: All state-altering operations have a constant time complexity, O(1).
17-
- __Comprehensive documentation__: The class is thoroughly documented, enabling IDEs to provide helpful tooltips that enhance the coding experience.
16+
- __High Efficiency :gear:__: All state-altering operations have a constant time complexity, O(1).
17+
- __Comprehensive documentation :books:__: The class is thoroughly documented, enabling IDEs to provide helpful tooltips that enhance the coding experience.
1818
- __Robust Error Handling__: Uncaught errors from background jobs triggered by `startExecution` are captured and can be accessed using the `extractUncaughtErrors` method.
1919
- **Fully covered** by rigorous unit tests.
2020
- Self-explanatory method names.

dist/zero-backpressure-semaphore.d.ts

+15-8
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,21 @@ export declare class ZeroBackpressureSemaphore<T, UncaughtErrorType = Error> {
8080
/**
8181
* startExecution
8282
*
83-
* This method resolves once the given job has started its execution, indicating that the
83+
* This method resolves once the given job has *started* its execution, indicating that the
8484
* semaphore has become available (i.e., allotted a slot for the job).
85-
* Users can leverage this to determine the start timestamp of a job. If the semaphore is too busy
86-
* to start a given job `X`, there is no reason to create another job `Y` until `X` has started.
85+
* Users can leverage this to prevent backpressure of pending jobs:
86+
* If the semaphore is too busy to start a given job `X`, there is no reason to create another
87+
* job `Y` until `X` has started.
8788
*
8889
* This method is particularly useful for executing multiple or background jobs, where no return
89-
* value is expected.
90+
* value is expected. It promotes a just-in-time approach, on which each job is pending execution
91+
* only when no other job is, thereby eliminating backpressure and reducing memory footprint.
9092
*
93+
* ### Graceful Termination
94+
* Method `waitForAllExecutingJobsToComplete` complements the typical use-cases of `startExecution`.
95+
* It can be used to perform post-processing, after all the currently-executing jobs have completed.
96+
*
97+
* ### Error Handling
9198
* If the job throws an error, it is captured by the semaphore and can be accessed via the
9299
* `extractUncaughtError` method. Users are encouraged to specify a custom `UncaughtErrorType`
93100
* generic parameter to the class if jobs may throw errors.
@@ -100,11 +107,11 @@ export declare class ZeroBackpressureSemaphore<T, UncaughtErrorType = Error> {
100107
* waitForCompletion
101108
*
102109
* This method executes the given job in a controlled manner, once the semaphore is available.
103-
* It resolves or rejects when the job has finished its execution, providing the returned value
104-
* or thrown error from the job.
110+
* It resolves or rejects when the job finishes execution, returning the job's value or propagating
111+
* any error it may throw.
105112
*
106-
* This method is useful when the flow depends on the job's execution, such as needing its return
107-
* value or handling any errors it may throw.
113+
* This method is useful when the flow depends on a job's execution to proceed, such as needing
114+
* its return value or handling any errors it may throw.
108115
*
109116
* ### Example Use Case
110117
* Suppose you have a route handler that needs to perform a specific code block with limited

dist/zero-backpressure-semaphore.js

+15-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/zero-backpressure-semaphore.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zero-backpressure-semaphore-typescript",
3-
"version": "3.0.2",
3+
"version": "3.0.3",
44
"description": "A classic semaphore with modern API, inspired by the RAII idiom. Offering backpressure control for enhanced efficiency, utilizing a communicative API that signals availability. Additionally, it incorporates mechanisms for graceful termination and error handling, making it suitable for complex scenarios.",
55
"repository": {
66
"type": "git",

src/zero-backpressure-semaphore.ts

+15-8
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,21 @@ export class ZeroBackpressureSemaphore<T, UncaughtErrorType = Error> {
125125
/**
126126
* startExecution
127127
*
128-
* This method resolves once the given job has started its execution, indicating that the
128+
* This method resolves once the given job has *started* its execution, indicating that the
129129
* semaphore has become available (i.e., allotted a slot for the job).
130-
* Users can leverage this to determine the start timestamp of a job. If the semaphore is too busy
131-
* to start a given job `X`, there is no reason to create another job `Y` until `X` has started.
130+
* Users can leverage this to prevent backpressure of pending jobs:
131+
* If the semaphore is too busy to start a given job `X`, there is no reason to create another
132+
* job `Y` until `X` has started.
132133
*
133134
* This method is particularly useful for executing multiple or background jobs, where no return
134-
* value is expected.
135+
* value is expected. It promotes a just-in-time approach, on which each job is pending execution
136+
* only when no other job is, thereby eliminating backpressure and reducing memory footprint.
135137
*
138+
* ### Graceful Termination
139+
* Method `waitForAllExecutingJobsToComplete` complements the typical use-cases of `startExecution`.
140+
* It can be used to perform post-processing, after all the currently-executing jobs have completed.
141+
*
142+
* ### Error Handling
136143
* If the job throws an error, it is captured by the semaphore and can be accessed via the
137144
* `extractUncaughtError` method. Users are encouraged to specify a custom `UncaughtErrorType`
138145
* generic parameter to the class if jobs may throw errors.
@@ -150,11 +157,11 @@ export class ZeroBackpressureSemaphore<T, UncaughtErrorType = Error> {
150157
* waitForCompletion
151158
*
152159
* This method executes the given job in a controlled manner, once the semaphore is available.
153-
* It resolves or rejects when the job has finished its execution, providing the returned value
154-
* or thrown error from the job.
160+
* It resolves or rejects when the job finishes execution, returning the job's value or propagating
161+
* any error it may throw.
155162
*
156-
* This method is useful when the flow depends on the job's execution, such as needing its return
157-
* value or handling any errors it may throw.
163+
* This method is useful when the flow depends on a job's execution to proceed, such as needing
164+
* its return value or handling any errors it may throw.
158165
*
159166
* ### Example Use Case
160167
* Suppose you have a route handler that needs to perform a specific code block with limited

0 commit comments

Comments
 (0)