本文整理汇总了C++中ObjectPool::Rundown方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectPool::Rundown方法的具体用法?C++ ObjectPool::Rundown怎么用?C++ ObjectPool::Rundown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectPool
的用法示例。
在下文中一共展示了ObjectPool::Rundown方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pool
TEST_F(ObjectPoolTest, EmptyPoolIssuance) {
ObjectPool<int> pool;
// Create the thread which will hold the shared pointer for awhile:
AutoRequired<HoldsSharedPtrThenQuits> thread;
pool(thread->m_ptr);
std::weak_ptr<int> ptrWeak = thread->m_ptr;
ASSERT_FALSE(ptrWeak.expired()) << "Object pool failed to issue a shared pointer as expected";
// Verify properties now that we've zeroized the limit:
pool.SetOutstandingLimit(0);
EXPECT_ANY_THROW(pool.SetOutstandingLimit(1)) << "An attempt to alter a zeroized outstanding limit did not throw an exception as expected";
EXPECT_ANY_THROW(pool.Wait()) << "An attempt to obtain an element on an empty pool did not throw an exception as expected";
// Now see if we can delay for the thread to back out:
m_create->Initiate();
pool.Rundown();
// Verify that it got released as expected:
ASSERT_TRUE(ptrWeak.expired()) << "Not all shared pointers issued by an object pool expired in a timely fashion";
}
示例2:
TEST_F(ObjectPoolTest, CanRundownOneIssued) {
// No conditions to be checked, we just know these routines should not deadlock.
ObjectPool<int> pool;
pool.Wait();
pool.Rundown();
}