Changeset View
Changeset View
Standalone View
Standalone View
src/test/rcu_tests.cpp
Show First 20 Lines • Show All 284 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(rcuptr_operator_test) { | ||||
copyptr = gptr; | copyptr = gptr; | ||||
BOOST_CHECK(gptr != nullptr); | BOOST_CHECK(gptr != nullptr); | ||||
BOOST_CHECK(gptr == oldPtr); | BOOST_CHECK(gptr == oldPtr); | ||||
BOOST_CHECK(gptr == copyptr); | BOOST_CHECK(gptr == copyptr); | ||||
BOOST_CHECK(gptr != altptr); | BOOST_CHECK(gptr != altptr); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(const_rcuptr_test) { | |||||
bool isDestroyed = false; | |||||
auto ptr = RCUPtr<const RCURefTestItem>::make([&] { isDestroyed = true; }); | |||||
// Now let's destroy it. | |||||
ptr = RCUPtr<const RCURefTestItem>(); | |||||
BOOST_CHECK(!isDestroyed); | |||||
RCULock::synchronize(); | |||||
BOOST_CHECK(isDestroyed); | |||||
} | |||||
class RCURefMoveTestItem { | class RCURefMoveTestItem { | ||||
const std::function<void()> cleanupfun; | const std::function<void()> cleanupfun; | ||||
public: | public: | ||||
explicit RCURefMoveTestItem(const std::function<void()> &fun) | explicit RCURefMoveTestItem(const std::function<void()> &fun) | ||||
: cleanupfun(fun) {} | : cleanupfun(fun) {} | ||||
~RCURefMoveTestItem() { cleanupfun(); } | ~RCURefMoveTestItem() { cleanupfun(); } | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |