10template <
typename BASE>
29 void go(
const char *title)
37template <
typename Base>
79template <
typename Test>
87 typename Test::Ptr t1 =
new Test(
"Test1");
88 typename Test::Ptr t2(t1);
89 typename Test::Ptr t3(t2);
94 typename Test::WPtr w1z;
95 typename Test::WPtr w2z;
98 typename Test::Ptr t1 =
new Test(
"Test2");
99 typename Test::WPtr w1 = t1;
104 typename Test::Ptr t1a = w1.lock();
105 typename Test::Ptr t2a = w2.
lock();
116 typename Test::WPtr z;
118 typename Test::Ptr tz = z.lock();
122 ASSERT_FALSE(tz) <<
"BUG ALERT #1";
126 ASSERT_FALSE(tz) <<
"BUG ALERT #2";
128 OPENVPN_LOG(
"w1z=" << w1z.use_count() <<
" w2z=" << w2z.use_count());
131 typename Test::Ptr x = w1z.lock();
132 typename Test::Ptr y = w2z.lock();
133 ASSERT_FALSE(x || y || !w1z.expired() || !w2z.expired()) <<
"BUG ALERT #3";
138 typename Test::Ptr t1 =
new Test(
"Test3");
139 typename Test::Ptr t2(t1);
140 typename Test::Ptr t3(t2);
142 t1->rc_release_notify([obj = t1.get()]()
145 OPENVPN_LOG(
"NOTIFY #1"); });
146 t2->rc_release_notify([obj = t2.get()]()
149 OPENVPN_LOG(
"NOTIFY #2"); });
150 t3->rc_release_notify([obj = t3.get()]()
153 OPENVPN_LOG(
"NOTIFY #3"); });
157 typename TestParent::Ptr t1 =
new TestParent(
"Test4");
158 typename Test::Ptr t2(t1);
159 typename TestParent::Ptr t3 = t2.template dynamic_pointer_cast<TestParent>();
167 test<TestType<RCWeak<thread_unsafe_refcount>>>();
172 test<TestType<RCWeak<thread_safe_refcount>>>();
TestParentType(const std::string &name_arg)
RCPtr< TestParentType > Ptr
RCWeakPtr< TestParentType > WPtr
TestType(const std::string &name_arg)
void go(const char *title)
RCWeakPtr< TestType > WPtr
std::string stopCollecting()
void swap(RCPtr &rhs) noexcept
swaps the contents of two RCPtr<T>
implements a weak pointer for reference counted objects.
Strong lock() const noexcept
Tries to upgrade the weak reference to a strong reference and returns that result.
void reset(const Strong &p) noexcept
Reassign this weak ptr to the object referenced by the given strong (RCPtr) pointer.
openvpn::LogOutputCollector * testLog
#define OPENVPN_LOG(args)
Support deferred server-side state creation when client connects.
const char * expected_output
TEST(misc, RCthreadUnsafe)