source/base: Remove unused ref constructor
We don't ever use this constructor and it was effectively package
private. Remove it as we don't ever need to add references to our
sd_event_source*.
Tested:
Built and run through unit test suite.
Change-Id: I1ca9fd4ecfdef1a3fd5aa2ca214be657c1a04b94
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/sdeventplus/source/base.cpp b/src/sdeventplus/source/base.cpp
index 55c2d10..09566f8 100644
--- a/src/sdeventplus/source/base.cpp
+++ b/src/sdeventplus/source/base.cpp
@@ -118,12 +118,6 @@
}
}
-Base::Base(const Event& event, sd_event_source* source) :
- event(event), source(source, event.getSdEvent())
-{
- set_userdata();
-}
-
Base::Base(const Event& event, sd_event_source* source, std::false_type) :
event(event), source(std::move(source), event.getSdEvent())
{
@@ -157,12 +151,6 @@
return *this;
}
-sd_event_source* Base::ref(sd_event_source* const& source,
- const internal::SdEvent*& sdevent)
-{
- return sdevent->sd_event_source_ref(source);
-}
-
void Base::drop(sd_event_source*&& source, const internal::SdEvent*& sdevent)
{
sdevent->sd_event_source_unref(source);
diff --git a/src/sdeventplus/source/base.hpp b/src/sdeventplus/source/base.hpp
index c14ad7f..c9c7562 100644
--- a/src/sdeventplus/source/base.hpp
+++ b/src/sdeventplus/source/base.hpp
@@ -6,7 +6,7 @@
#include <functional>
#include <sdeventplus/event.hpp>
#include <sdeventplus/internal/utils.hpp>
-#include <stdplus/handle/copyable.hpp>
+#include <stdplus/handle/managed.hpp>
#include <systemd/sd-bus.h>
#include <type_traits>
@@ -114,15 +114,6 @@
Event event;
/** @brief Constructs a basic event source wrapper
- * Adds a reference to the source
- *
- * @param[in] event - The event associated with the source
- * @param[in] source - The underlying sd_event_source wrapped
- * @throws SdEventError for underlying sd_event errors
- */
- Base(const Event& event, sd_event_source* source);
-
- /** @brief Constructs a basic event source wrapper
* Owns the passed reference to the source
* This ownership is exception safe and will properly free the
* source in the case of an exception during construction
@@ -174,13 +165,10 @@
}
private:
- static sd_event_source* ref(sd_event_source* const& source,
- const internal::SdEvent*& sdevent);
static void drop(sd_event_source*&& source,
const internal::SdEvent*& sdevent);
- stdplus::Copyable<sd_event_source*, const internal::SdEvent*>::Handle<drop,
- ref>
+ stdplus::Managed<sd_event_source*, const internal::SdEvent*>::Handle<drop>
source;
Callback prepare;
diff --git a/test/source/base.cpp b/test/source/base.cpp
index 2139dd0..27e5bc3 100644
--- a/test/source/base.cpp
+++ b/test/source/base.cpp
@@ -30,9 +30,6 @@
class BaseImpl : public Base
{
public:
- BaseImpl(const Event& event, sd_event_source* source) : Base(event, source)
- {
- }
BaseImpl(const Event& event, sd_event_source* source, std::false_type) :
Base(event, source, std::false_type())
{
@@ -115,25 +112,6 @@
}
};
-TEST_F(BaseTest, NewBaseRef)
-{
- EXPECT_CALL(mock, sd_event_ref(expected_event))
- .WillOnce(Return(expected_event));
- EXPECT_CALL(mock, sd_event_source_ref(expected_source))
- .WillOnce(Return(expected_source));
- void* userdata;
- EXPECT_CALL(mock, sd_event_source_set_userdata(expected_source, testing::_))
- .WillOnce(DoAll(SaveArg<1>(&userdata), Return(nullptr)));
- BaseImpl source(*event, expected_source);
- EXPECT_EQ(&source, userdata);
- EXPECT_EQ(expected_source, source.get());
- EXPECT_NE(event.get(), &source.get_event());
- EXPECT_EQ(expected_event, source.get_event().get());
- EXPECT_FALSE(source.get_prepare());
-
- expect_base_destruct(*event, expected_source);
-}
-
TEST_F(BaseTest, NewBaseNoRef)
{
EXPECT_CALL(mock, sd_event_ref(expected_event))