Skip to content

Commit 0079777

Browse files
committed
[C++ Wrapper] Remove close() method from Publication/ExclusivePublication, i.e. the underlying C publications will be closed when the corresponding C++ object is destroyed.
1 parent 647807b commit 0079777

3 files changed

Lines changed: 2 additions & 54 deletions

File tree

aeron-client/src/main/cpp_wrapper/ExclusivePublication.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,6 @@ class ExclusivePublication
8282
}
8383
}
8484

85-
inline void close()
86-
{
87-
if (aeron_exclusive_publication_close(m_publication, nullptr, nullptr) < 0)
88-
{
89-
AERON_MAP_ERRNO_TO_SOURCED_EXCEPTION_AND_THROW;
90-
}
91-
92-
m_publication = nullptr;
93-
}
94-
9585
inline void revokeOnClose()
9686
{
9787
aeron_exclusive_publication_revoke_on_close(m_publication);

aeron-client/src/main/cpp_wrapper/Publication.h

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,6 @@ class Publication
114114
}
115115
}
116116

117-
inline void close()
118-
{
119-
if (aeron_publication_close(m_publication, nullptr, nullptr) < 0)
120-
{
121-
AERON_MAP_ERRNO_TO_SOURCED_EXCEPTION_AND_THROW;
122-
}
123-
124-
m_publication = nullptr;
125-
}
126-
127117
/**
128118
* Media address for delivery to the channel.
129119
*
@@ -278,11 +268,6 @@ class Publication
278268
std::int64_t position = aeron_publication_position(m_publication);
279269
if (AERON_PUBLICATION_ERROR == position)
280270
{
281-
if (nullptr == m_publication)
282-
{
283-
return AERON_PUBLICATION_CLOSED;
284-
}
285-
286271
AERON_MAP_ERRNO_TO_SOURCED_EXCEPTION_AND_THROW;
287272
}
288273

@@ -301,11 +286,6 @@ class Publication
301286
std::int64_t limit = aeron_publication_position_limit(m_publication);
302287
if (AERON_PUBLICATION_ERROR == limit)
303288
{
304-
if (nullptr == m_publication)
305-
{
306-
return AERON_PUBLICATION_CLOSED;
307-
}
308-
309289
AERON_MAP_ERRNO_TO_SOURCED_EXCEPTION_AND_THROW;
310290
}
311291

@@ -415,11 +395,6 @@ class Publication
415395
(void *)&reservedValueSupplier);
416396
if (AERON_PUBLICATION_ERROR == position)
417397
{
418-
if (nullptr == m_publication)
419-
{
420-
return AERON_PUBLICATION_CLOSED;
421-
}
422-
423398
AERON_MAP_ERRNO_TO_SOURCED_EXCEPTION_AND_THROW;
424399
}
425400

@@ -488,11 +463,6 @@ class Publication
488463

489464
if (AERON_PUBLICATION_ERROR == position)
490465
{
491-
if (nullptr == m_publication)
492-
{
493-
return AERON_PUBLICATION_CLOSED;
494-
}
495-
496466
AERON_MAP_ERRNO_TO_SOURCED_EXCEPTION_AND_THROW;
497467
}
498468

@@ -555,11 +525,6 @@ class Publication
555525

556526
if (AERON_PUBLICATION_ERROR == position)
557527
{
558-
if (nullptr == m_publication)
559-
{
560-
return AERON_PUBLICATION_CLOSED;
561-
}
562-
563528
AERON_MAP_ERRNO_TO_SOURCED_EXCEPTION_AND_THROW;
564529
}
565530

@@ -605,11 +570,6 @@ class Publication
605570
m_publication, static_cast<std::size_t>(length), &temp_claim);
606571
if (AERON_PUBLICATION_ERROR == position)
607572
{
608-
if (nullptr == m_publication)
609-
{
610-
return AERON_PUBLICATION_CLOSED;
611-
}
612-
613573
AERON_MAP_ERRNO_TO_SOURCED_EXCEPTION_AND_THROW;
614574
}
615575

aeron-client/src/test/cpp_wrapper/PublicationRevokeTest.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ TEST_P(PublicationRevokeTest, revokeTestSimple)
118118
POLL_FOR(0 < pub->offer(buffer, 0, length), invoker);
119119

120120
pub->revokeOnClose();
121-
pub->close();
122-
123-
ASSERT_EQ(AERON_PUBLICATION_CLOSED, pub->offer(buffer, 0, length));
121+
pub.reset();
124122

125123
POLL_FOR(1 == imageUnavailable, invoker);
126124

@@ -202,7 +200,7 @@ TEST_P(PublicationRevokeTest, revokeTestExclusive)
202200

203201
POLL_FOR(2 == imageUnavailable, invoker);
204202

205-
pub2->close();
203+
pub2.reset();
206204

207205
ASSERT_EQ(1, aeron->countersReader().getCounterValue(AERON_SYSTEM_COUNTER_PUBLICATIONS_REVOKED));
208206
ASSERT_EQ(expectedPublicationImagesRevoked, aeron->countersReader().getCounterValue(AERON_SYSTEM_COUNTER_PUBLICATION_IMAGES_REVOKED));

0 commit comments

Comments
 (0)