Skip to content

Commit 8756c99

Browse files
committed
Parameterize over T instead of Payload.
1 parent d2d7354 commit 8756c99

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/mixins/MemoryMixin.h

+7-8
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace reactivesocket {
3030
/// implicitly specified as virtual, depending on whether the Base class
3131
/// is implementing the (virtual) methods of the
3232
/// Subscription or the Subscriber interface.
33-
template <typename Base, typename Payload = Payload>
33+
template <typename Base, typename T = Payload>
3434
class MemoryMixin : public Base {
3535
static_assert(
3636
std::is_base_of<IntrusiveDeleter, Base>::value,
@@ -42,8 +42,8 @@ class MemoryMixin : public Base {
4242
~MemoryMixin() {}
4343

4444
/// @{
45-
/// Publisher<Payload>
46-
void subscribe(Subscriber<Payload>& subscriber) {
45+
/// Publisher<T>
46+
void subscribe(Subscriber<T>& subscriber) {
4747
Base::incrementRefCount();
4848
Base::subscribe(subscriber);
4949
}
@@ -62,13 +62,13 @@ class MemoryMixin : public Base {
6262
/// @}
6363

6464
/// @{
65-
/// Subscriber<Payload>
65+
/// Subscriber<T>
6666
void onSubscribe(Subscription& subscription) {
6767
Base::incrementRefCount();
6868
Base::onSubscribe(subscription);
6969
}
7070

71-
void onNext(Payload payload) {
71+
void onNext(T payload) {
7272
Base::onNext(std::move(payload));
7373
}
7474

@@ -126,11 +126,10 @@ class WithIntrusiveDeleter {
126126

127127
} // namespace details
128128

129-
template <typename Base, typename Payload = Payload, typename... TArgs>
129+
template <typename Base, typename T = Payload, typename... TArgs>
130130
Base& createManagedInstance(TArgs&&... args) {
131131
auto* instance =
132-
new MemoryMixin<typename details::WithIntrusiveDeleter<Base>::T,
133-
Payload>(
132+
new MemoryMixin<typename details::WithIntrusiveDeleter<Base>::T, T>(
134133
std::forward<TArgs>(args)...);
135134
return *instance;
136135
}

test/simple/SubscriberNonPayloadTest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class FooSubscriber : public IntrusiveDeleter, public Subscriber<Foo> {
2424
};
2525

2626
int main(int argc, char** argv) {
27-
auto& m = createManagedInstance<FooSubscriber, Foo>();
27+
auto& m = createManagedInstance<FooSubscriber, Foo>();
2828
m.onNext(Foo("asdf"));
2929
return 0;
3030
}

0 commit comments

Comments
 (0)