Skip to content

Commit 94d6421

Browse files
yschimkelehecka
authored andcommitted
rename Producer to Publisher to match java Spec (#20)
1 parent eda419b commit 94d6421

19 files changed

+59
-59
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ include_directories(${CMAKE_SOURCE_DIR})
1616
add_library(
1717
ReactiveSocket
1818
reactive-streams-cpp/Mocks.h
19-
reactive-streams-cpp/Producer.h
19+
reactive-streams-cpp/Publisher.h
2020
reactive-streams-cpp/README.md
2121
reactive-streams-cpp/Subscriber.h
2222
reactive-streams-cpp/Subscription.h
@@ -47,7 +47,7 @@ add_library(
4747
reactivesocket-cpp/src/mixins/LoggingMixin.h
4848
reactivesocket-cpp/src/mixins/MemoryMixin.h
4949
reactivesocket-cpp/src/mixins/MixinTerminator.h
50-
reactivesocket-cpp/src/mixins/ProducerMixin.h
50+
reactivesocket-cpp/src/mixins/PublisherMixin.h
5151
reactivesocket-cpp/src/mixins/README.md
5252
reactivesocket-cpp/src/mixins/SinkIfMixin.h
5353
reactivesocket-cpp/src/mixins/SourceIfMixin.h

reactive-streams-cpp/Mocks.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88

99
#include <gmock/gmock.h>
1010

11-
#include "reactive-streams-cpp/Producer.h"
11+
#include "reactive-streams-cpp/Publisher.h"
1212
#include "reactive-streams-cpp/Subscriber.h"
1313
#include "reactive-streams-cpp/Subscription.h"
1414
#include "reactive-streams-cpp/utilities/Ownership.h"
1515

1616
namespace lithium {
1717
namespace reactivestreams {
1818

19-
/// GoogleMock-compatible Producer implementation for fast prototyping.
20-
/// UnmanagedMockProducer's lifetime MUST be managed externally.
19+
/// GoogleMock-compatible Publisher implementation for fast prototyping.
20+
/// UnmanagedMockPublisher's lifetime MUST be managed externally.
2121
template <typename T, typename E = std::exception_ptr>
22-
class UnmanagedMockProducer : public Producer<T, E> {
22+
class UnmanagedMockPublisher : public Publisher<T, E> {
2323
public:
2424
MOCK_METHOD1_T(subscribe_, void(Subscriber<T, E>* subscriber));
2525

@@ -93,7 +93,7 @@ class MockSubscriber : public Subscriber<T, E> {
9393

9494
void onSubscribe(Subscription& subscription) override {
9595
subscription_ = &subscription;
96-
// We allow registering the same subscriber with multiple Producers.
96+
// We allow registering the same subscriber with multiple Publishers.
9797
// Otherwise, we could get rid of reference counting.
9898
refCount_.increment();
9999
onSubscribe_(&subscription);

reactive-streams-cpp/Producer.h renamed to reactive-streams-cpp/Publisher.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,24 @@ class Subscriber;
1818
/// * copy from specification for JVM,
1919
///
2020
/// Life cycle considerations:
21-
/// 1. The Producer is not owned by Subscriber or Subscription.
22-
/// 2. The Producer can be a temporary object, as it is only used to capture the
23-
/// indirection in creation of the Subscription instance. Producer's lifetime
21+
/// 1. The Publisher is not owned by Subscriber or Subscription.
22+
/// 2. The Publisher can be a temporary object, as it is only used to capture the
23+
/// indirection in creation of the Subscription instance. Publisher's lifetime
2424
/// does not need to extend beyond a lifetime of any of the Subscribers.
2525
template <typename T, typename E = std::exception_ptr>
26-
class Producer {
26+
class Publisher {
2727
public:
28-
virtual ~Producer() = default;
28+
virtual ~Publisher() = default;
2929

30-
/// Establishes an abstract subscription between Subscriber and Producer, by
30+
/// Establishes an abstract subscription between Subscriber and Publisher, by
3131
/// providing the former with an instance of Subscription.
3232
///
3333
/// Must call Subscriber::onSubscribe synchronously to provide a valid
3434
/// Subscription.
3535
///
3636
/// Life cycle considerations:
37-
/// 1. No ownership of the Subscriber is assumed by the Producer.
38-
/// 2. The Subsciber pointer MUST remain valid until the Producer calls
37+
/// 1. No ownership of the Subscriber is assumed by the Publisher.
38+
/// 2. The Subsciber pointer MUST remain valid until the Publisher calls
3939
/// Subscriber::{onComplete,onError}. See "unsubscribe handshake" for more
4040
/// details.
4141
virtual void subscribe(Subscriber<T, E>& subscriber) = 0;

reactive-streams-cpp/Subscriber.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ class Subscription;
2121
/// * add a rule to ensure single terminal signal,
2222
///
2323
/// Life cycle considerations:
24-
/// 1. The Subscriber is not owned by any Producer, nor it owns a Subscription.
25-
/// 2. Per "unsubscribe handshake", the Producer MUST always send either
24+
/// 1. The Subscriber is not owned by any Publisher, nor it owns a Subscription.
25+
/// 2. Per "unsubscribe handshake", the Publisher MUST always send either
2626
/// ::{onComplete,onError} as the last signal to the Subscriber.
2727
/// This holds even if an unsubscribe sequence is initiated by the Subscriber
2828
/// calling Subscription::cancel. Therefore, it is perfectly possible for a
2929
/// Subscriber to deallocate any resources it holds in ::{onComplete,onError}.
3030
/// 3. Note that no part of ReactiveStreams specification requires the
3131
/// Subscriber to be heap-allocated. However, if it is the case, from the
32-
/// perspective of Producer-Subscriber interaction, it is valid for the
32+
/// perspective of Publisher-Subscriber interaction, it is valid for the
3333
/// Subscriber to `delete this;` as the last statement in
3434
/// ::{onComplete,onError}.
3535
template <typename T, typename E = std::exception_ptr>
@@ -40,7 +40,7 @@ class Subscriber {
4040

4141
virtual ~Subscriber() = default;
4242

43-
/// Called synchronously from Producer::subscribe to finish the initial
43+
/// Called synchronously from Publisher::subscribe to finish the initial
4444
/// handshake.
4545
///
4646
/// Life cycle considerations:
@@ -49,30 +49,30 @@ class Subscriber {
4949
/// Subscription::cancel. See "unsubscribe handshake" for more details.
5050
virtual void onSubscribe(Subscription& subscription) = 0;
5151

52-
/// Called by or on behalf of Producer when it wishes to deliver the next
52+
/// Called by or on behalf of Publisher when it wishes to deliver the next
5353
/// element on a subscription.
5454
///
5555
/// If a Subscriber calls `Subscription::request(1); Subscription::cancel()`,
5656
/// ::onNext might be invoked after or during the call to
57-
/// Subscription::cancel. In this case, however, the Producer MUST eventually
57+
/// Subscription::cancel. In this case, however, the Publisher MUST eventually
5858
/// call one of ::{onComplete,onError} to finish the "unsubscribe handshake".
5959
///
6060
/// The method MUST NOT be called after or during an invocation of
6161
/// ::{onComplete,onError}.
6262
virtual void onNext(T element) = 0;
6363

64-
/// Called by or on behalf of Producer when it wishes to terminate the
64+
/// Called by or on behalf of Publisher when it wishes to terminate the
6565
/// abstract subscription gracefully.
6666
///
67-
/// Subscriber pointer passed to the Producer::subscribe may become invalid as
67+
/// Subscriber pointer passed to the Publisher::subscribe may become invalid as
6868
/// a result of this call. No other method of the Subscriber can be called
6969
/// after or during an invocation of ::onComplete.
7070
virtual void onComplete() = 0;
7171

72-
/// Called by or on behalf of Producer when it wishes to terminate the
72+
/// Called by or on behalf of Publisher when it wishes to terminate the
7373
/// abstract subscription with an error.
7474
///
75-
/// Subscriber pointer passed to the Producer::subscribe may become invalid as
75+
/// Subscriber pointer passed to the Publisher::subscribe may become invalid as
7676
/// a result of this call. No other method of the Subscriber can be called
7777
/// after or during an invocation of ::onError.
7878
virtual void onError(E ex) = 0;

reactive-streams-cpp/Subscription.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
namespace lithium {
99
namespace reactivestreams {
1010

11-
/// Represents a connection between Producer and Subscriber established by an
12-
/// invocation of Subscriber::onSubscribe performed by the Producer.
11+
/// Represents a connection between Publisher and Subscriber established by an
12+
/// invocation of Subscriber::onSubscribe performed by the Publisher.
1313
///
1414
/// Rules:
1515
/// TODO(stupaq):
@@ -20,8 +20,8 @@ namespace reactivestreams {
2020
/// Life cycle considerations:
2121
/// 1. Subscription is borrowed to the Subscriber in Subscriber::onSubscribe.
2222
/// 2. Per "unsubscribe handshake", the Subscriber MUST invoke ::cancel as the
23-
/// last signal to the Producer. This holds even if an unsubscribe sequence
24-
/// is initiated by the Producer calling Subscriber::{onComplete, onError}.
23+
/// last signal to the Publisher. This holds even if an unsubscribe sequence
24+
/// is initiated by the Publisher calling Subscriber::{onComplete, onError}.
2525
/// Therefore, it is valid for the Subscription to free any resources it holds
2626
/// in ::cancel.
2727
/// 3. Note that no part of ReactiveStreams specification requires the
@@ -30,16 +30,16 @@ namespace reactivestreams {
3030
/// `delete this;` as the last statement in ::cancel.
3131
///
3232
/// Note that it is valid, from the perspective of the ReactiveStreams
33-
/// specification, for a Subscription and a Producer to be the same object,
34-
/// as long as the Producer has only one Subscriber.
33+
/// specification, for a Subscription and a Publisher to be the same object,
34+
/// as long as the Publisher has only one Subscriber.
3535
class Subscription {
3636
public:
3737
virtual ~Subscription() = default;
3838

3939
/// Called by the Subscriber to communicate readiness to accept `n` more
4040
/// elements of the stream.
4141
///
42-
/// It is legal for Producer to call Subscriber::onNext synchronously from
42+
/// It is legal for Publisher to call Subscriber::onNext synchronously from
4343
/// ::request. Similarily, it is possible for Subscriber to invoke
4444
/// ::request from Subscriber::onNext. To break the symmetry and prevent
4545
/// unbounded stack growth, implementation of ::request is required to place
@@ -58,7 +58,7 @@ class Subscription {
5858
/// }
5959
/// // Attempt to push (via Subscriber::onNext) any pending elements that
6060
/// // were queued up due to null allowance. This could involve a call to
61-
/// // ::request of a subscription that feeds this Producer with data.
61+
/// // ::request of a subscription that feeds this Publisher with data.
6262
/// }
6363
///
6464
virtual void request(size_t n) = 0;

reactive-streams-cpp/TARGETS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cpp_library(
22
name = 'api',
33
headers = [
4-
'Producer.h',
4+
'Publisher.h',
55
'Subscriber.h',
66
'Subscription.h',
77
],

reactive-streams-cpp/examples/Examples.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ TEST(Examples, SelfManagedMocks) {
1414
// double-free bugs.
1515
int value = 42;
1616

17-
UnmanagedMockProducer<int> producer;
17+
UnmanagedMockPublisher<int> producer;
1818
auto* subscription = &makeMockSubscription();
1919
auto* subscriber = &makeMockSubscriber<int>();
2020
{
@@ -31,7 +31,7 @@ TEST(Examples, SelfManagedMocks) {
3131
// deliver one element, despite Subscription::cancel() has been
3232
// called.
3333
subscriber->onNext(value);
34-
// This Producer never spontaneously terminates the subscription,
34+
// This Publisher never spontaneously terminates the subscription,
3535
// hence we can respond with onComplete unconditionally.
3636
subscriber->onComplete();
3737
subscriber = nullptr;
@@ -50,7 +50,7 @@ TEST(Examples, UnmanagedMocks) {
5050
// double-free bugs.
5151
int value = 42;
5252

53-
UnmanagedMockProducer<int> producer;
53+
UnmanagedMockPublisher<int> producer;
5454
UnmanagedMockSubscription subscription;
5555
UnmanagedMockSubscriber<int> subscriber;
5656
{
@@ -67,7 +67,7 @@ TEST(Examples, UnmanagedMocks) {
6767
// deliver one element, despite Subscription::cancel() has been
6868
// called.
6969
subscriber.onNext(value);
70-
// This Producer never spontaneously terminates the subscription,
70+
// This Publisher never spontaneously terminates the subscription,
7171
// hence we can respond with onComplete unconditionally.
7272
subscriber.onComplete();
7373
}));

reactivesocket-cpp/TARGETS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ cpp_library(
2929
'src/mixins/MemoryMixin.h',
3030
'src/mixins/MixinTerminator.h',
3131
'src/mixins/LoggingMixin.h',
32-
'src/mixins/ProducerMixin.h',
32+
'src/mixins/PublisherMixin.h',
3333
'src/mixins/StreamIfMixin.h',
3434
'src/mixins/SinkIfMixin.h',
3535
'src/mixins/SourceIfMixin.h',

reactivesocket-cpp/src/ReactiveStreamsCompat.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#pragma once
55

6-
#include "reactive-streams-cpp/Producer.h"
6+
#include "reactive-streams-cpp/Publisher.h"
77
#include "reactive-streams-cpp/Subscriber.h"
88
#include "reactive-streams-cpp/Subscription.h"
99

@@ -28,7 +28,7 @@ class SubscriptionPtr;
2828
namespace reactivesocket {
2929

3030
template <typename T>
31-
using Producer = reactivestreams::Producer<T, folly::exception_wrapper>;
31+
using Publisher = reactivestreams::Publisher<T, folly::exception_wrapper>;
3232
template <typename T>
3333
using Subscriber = reactivestreams::Subscriber<T, folly::exception_wrapper>;
3434
using Subscription = reactivestreams::Subscription;

reactivesocket-cpp/src/RequestHandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class RequestHandler {
1515

1616
/// Handles a new Channel requested by the other end.
1717
///
18-
/// Modelled after Producer::subscribe, hence must synchronously call
18+
/// Modelled after Publisher::subscribe, hence must synchronously call
1919
/// Subscriber::onSubscribe, and provide a valid Subscription.
2020
virtual Subscriber<Payload>& handleRequestChannel(
2121
Payload request,

0 commit comments

Comments
 (0)