Skip to content

Commit 9512a48

Browse files
committed
Adding glossary while clarifying intents.
1 parent 4ee1058 commit 9512a48

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

README.md

+23-12
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,20 @@ followed by a possibly unbounded number of `onNext` signals (as requested by `Su
6666
#### NOTES
6767

6868
- The specifications below use binding words in capital letters from https://www.ietf.org/rfc/rfc2119.txt
69-
- The terms `emit`, `signal` or `send` are interchangeable. The specifications below will use `signal`.
70-
- The terms `synchronously` or `synchronous` refer to executing in the calling `Thread`.
71-
- The term "return normally" means "only throws exceptions that are explicitly allowed by the rule".
69+
70+
### Glossary
71+
72+
| Term | Definition |
73+
| ------------------------- | ------------------------------------------------------------------------------------------------------ |
74+
| <a name="term_signal">Signal</a> | As a noun: one of the `onSubscribe`, `onNext`, `onComplete` or `onError` methods. As a verb: calling/invoking a signal. |
75+
| <a name="term_demand">Demand</a> | As a noun, the aggregated number of elements requested by a Subscriber which is yet to be delivered (fulfilled) by the Publisher. As a verb, the act of `request`-ing more elements. |
76+
| <a name="term_sync">Synchronous(ly)</a> | Executes on the calling Thread. |
77+
| <a name="term_return_normally">Return normally</a> | Returns a value of the declared type alternatively throws an exception permitted by this specification. The only legal way to signal failure to a `Subscriber` is via the `onError` method.|
78+
| <a name="term_emit_element">Emit element</a> | Signalling a value to `onNext`. |
79+
| <a name="term_responsivity">Responsivity</a> | Readiness/ability to respond. In this document used to indicate that the different components should not impair eachothers ability to respond. |
80+
| <a name="term_non-obstructing">Non-obstructing</a> | Quality describing a method which is as quick to execute as possible—on the calling thread. This means, for example, avoids heavy computations and other things that would stall the caller´s thread of execution. |
81+
| <a name="term_terminal_state">Terminal state</a> | For a Publisher: The point where `onComplete` or `onError` has been signalled. For a Subscriber: The point where an `onComplete` or `onError` has been received.|
82+
7283

7384
### SPECIFICATION
7485

@@ -94,7 +105,7 @@ public interface Publisher<T> {
94105
| [:bulb:](#1.5 "1.5 explained") | *The intent of this rule is to make it clear that a Publisher is responsible for notifying its Subscribers that it has reached a `terminal state`—Subscribers can then act on this information; clean up resources, etc.* |
95106
| <a name="1.6">6</a> | If a `Publisher` signals either `onError` or `onComplete` on a `Subscriber`, that `Subscriber`’s `Subscription` MUST be considered cancelled. |
96107
| [:bulb:](#1.6 "1.6 explained") | *The intent of this rule is to make sure that a Subscription is treated the same no matter if it was cancelled, the Publisher signalled onError or onComplete.* |
97-
| <a name="1.7">7</a> | Once a terminal state has been signaled (`onError`, `onComplete`) it is REQUIRED that no further signals occur. |
108+
| <a name="1.7">7</a> | Once a `terminal state` has been signaled (`onError`, `onComplete`) it is REQUIRED that no further signals occur. |
98109
| [:bulb:](#1.7 "1.7 explained") | *The intent of this rule is to make sure that onError and onComplete are the final states of an interaction between Publisher and Subscriber.* |
99110
| <a name="1.8">8</a> | If a `Subscription` is cancelled its `Subscriber` MUST eventually stop being signaled. |
100111
| [:bulb:](#1.8 "1.8 explained") | *The intent of this rule is to make sure that Publishers respect a Subscriber’s request to cancel a Subscription when Subscription.cancel() has been called.* |
@@ -118,8 +129,8 @@ public interface Subscriber<T> {
118129

119130
| ID | Rule |
120131
| ------------------------- | ------------------------------------------------------------------------------------------------------ |
121-
| <a name="2.1">1</a> | A `Subscriber` MUST signal demand via `Subscription.request(long n)` to receive `onNext` signals. |
122-
| [:bulb:](#2.1 "2.1 explained") | *The intent of this rule is to establish that it is the responsibility of the Subscriber to signal when, and how many, elements it is able and willing to receive.* |
132+
| <a name="2.1">1</a> | A `Subscriber` MUST communicate demand via `Subscription.request(long n)` to receive `onNext` signals. |
133+
| [:bulb:](#2.1 "2.1 explained") | *The intent of this rule is to establish that it is the responsibility of the Subscriber to communicate when, and how many, elements it is able and willing to receive.* |
123134
| <a name="2.2">2</a> | If a `Subscriber` suspects that its processing of signals will negatively impact its `Publisher`’s responsivity, it is RECOMMENDED that it asynchronously dispatches its signals. |
124135
| [:bulb:](#2.2 "2.2 explained") | *The intent of this rule is that a Subscriber should not impede the progress of the Publisher from an execution point-of-view. In other words, the Subscriber should not starve the Publisher from CPU cycles.* |
125136
| <a name="2.3">3</a> | `Subscriber.onComplete()` and `Subscriber.onError(Throwable t)` MUST NOT call any methods on the `Subscription` or the `Publisher`. |
@@ -183,11 +194,11 @@ public interface Subscription {
183194
| <a name="3.13">13</a> | While the `Subscription` is not cancelled, `Subscription.cancel()` MUST request the `Publisher` to eventually drop any references to the corresponding subscriber. |
184195
| [:bulb:](#3.13 "3.13 explained") | *The intent of this rule is to make sure that Subsribers can be properly garbage-collected after their subscription no longer being valid. Re-subscribing with the same Subscriber object is discouraged [see [2.12](#2.12)], but this specification does not mandate that it is disallowed since that would mean having to store previously cancelled subscriptions indefinitely.* |
185196
| <a name="3.14">14</a> | While the `Subscription` is not cancelled, calling `Subscription.cancel` MAY cause the `Publisher`, if stateful, to transition into the `shut-down` state if no other `Subscription` exists at this point [see [1.9](#1.9)]. |
186-
| [:bulb:](#3.14 "3.14 explained") | *The intent of this rule is to allow for Publishers to not accept new Subscribers in response to a cancellation signal.* |
187-
| <a name="3.15">15</a> | Calling `Subscription.cancel` MUST return normally. The only legal way to signal failure to a `Subscriber` is via the `onError` method. |
188-
| [:bulb:](#3.15 "3.15 explained") | *The intent of this rule is to disallow implementations to throw exceptions in response to `cancel` being called, instead directing implementations to signal exceptions through the Subscriber’s `onError`.* |
189-
| <a name="3.16">16</a> | Calling `Subscription.request` MUST return normally. The only legal way to signal failure to a `Subscriber` is via the `onError` method. |
190-
| [:bulb:](#3.16 "3.16 explained") | *The intent of this rule is to disallow implementations to throw exceptions in response to `request` being called, instead directing implementations to signal exceptions through the Subscriber’s `onError`.* |
197+
| [:bulb:](#3.14 "3.14 explained") | *The intent of this rule is to allow for Publishers to signal `onComplete` or `onError` following `onSubscribe` for new Subscribers in response to a cancellation signal from an existing Subscriber.* |
198+
| <a name="3.15">15</a> | Calling `Subscription.cancel` MUST return normally. |
199+
| [:bulb:](#3.15 "3.15 explained") | *The intent of this rule is to disallow implementations to throw exceptions in response to `cancel` being called.* |
200+
| <a name="3.16">16</a> | Calling `Subscription.request` MUST return normally. |
201+
| [:bulb:](#3.16 "3.16 explained") | *The intent of this rule is to disallow implementations to throw exceptions in response to `request` being called.* |
191202
| <a name="3.17">17</a> | A `Subscription` MUST support an unbounded number of calls to request and MUST support a demand (sum requested - sum delivered) up to 2^63-1 (`java.lang.Long.MAX_VALUE`). A demand equal or greater than 2^63-1 (`java.lang.Long.MAX_VALUE`) MAY be considered by the `Publisher` as “effectively unbounded”. |
192203
| [:bulb:](#3.17 "3.17 explained") | *The intent of this rule is to establish that the Subscriber can request an unbounded number of elements, in any increment above 0 [see [3:9](#3.9)], in any number of invocations of `request`. As it is not feasibly reachable with current or foreseen hardware within a reasonable amount of time (1 element per nanosecond would take 292 years) to fulfill a demand of 2^63-1, it is allowed for a Publisher to stop tracking demand beyond this point.* |
193204

@@ -266,7 +277,7 @@ Then the maximum number of elements that may arrive—until more demand is signa
266277

267278
These bounds must be respected by a publisher independent of whether the source it represents can be backpressured or not. In the case of sources whose production rate cannot be influenced—for example clock ticks or mouse movement—the publisher must choose to either buffer or drop elements to obey the imposed bounds.
268279

269-
Subscribers signaling a demand for one element after the reception of an element effectively implement a Stop-and-Wait protocol where the demand signal is equivalent to acknowledgement. By providing demand for multiple elements the cost of acknowledgement is amortized. It is worth noting that the subscriber is allowed to signal demand at any point in time, allowing it to avoid unnecessary delays between the publisher and the subscriber (i.e. keeping its input buffer filled without having to wait for full round-trips).
280+
Subscribers signaling a demand for one element after the reception of an element effectively implement a Stop-and-Wait protocol where the demand signal is equivalent to acknowledgement. By providing demand for multiple elements the cost of acknowledgement is amortized. It is worth noting that the subscriber is allowed to communicate demand at any point in time, allowing it to avoid unnecessary delays between the publisher and the subscriber (i.e. keeping its input buffer filled without having to wait for full round-trips).
270281

271282
## Legal
272283

0 commit comments

Comments
 (0)