本文整理汇总了C++中BList::LastItem方法的典型用法代码示例。如果您正苦于以下问题:C++ BList::LastItem方法的具体用法?C++ BList::LastItem怎么用?C++ BList::LastItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BList
的用法示例。
在下文中一共展示了BList::LastItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestBlockCache
void BlockCacheConcurrencyTest::TestBlockCache(BBlockCache *theCache,
bool isMallocTest)
{
BList cacheList;
BList nonCacheList;
thread_id theThread = find_thread(NULL);
// Do everything eight times to ensure the test runs long
// enough to check for concurrency problems.
for (int j = 0; j < 8; j++) {
// Perform a series of gets, saves and frees
for (int i = 0; i < numBlocksInCache / 2; i++) {
GetBlock(theCache, sizeOfBlocksInCache, theThread, &cacheList, &nonCacheList);
GetBlock(theCache, sizeOfBlocksInCache, theThread, &cacheList, &nonCacheList);
GetBlock(theCache, sizeOfNonCacheBlocks, theThread, &cacheList, &nonCacheList);
GetBlock(theCache, sizeOfNonCacheBlocks, theThread, &cacheList, &nonCacheList);
SaveBlock(theCache, cacheList.ItemAt(cacheList.CountItems() / 2),
sizeOfBlocksInCache, theThread, &cacheList, &nonCacheList);
SaveBlock(theCache, nonCacheList.ItemAt(nonCacheList.CountItems() / 2),
sizeOfNonCacheBlocks, theThread, &cacheList, &nonCacheList);
GetBlock(theCache, sizeOfBlocksInCache, theThread, &cacheList, &nonCacheList);
GetBlock(theCache, sizeOfBlocksInCache, theThread, &cacheList, &nonCacheList);
GetBlock(theCache, sizeOfNonCacheBlocks, theThread, &cacheList, &nonCacheList);
GetBlock(theCache, sizeOfNonCacheBlocks, theThread, &cacheList, &nonCacheList);
FreeBlock(cacheList.ItemAt(cacheList.CountItems() / 2),
sizeOfBlocksInCache, isMallocTest, theThread, &cacheList, &nonCacheList);
FreeBlock(nonCacheList.ItemAt(nonCacheList.CountItems() / 2),
sizeOfNonCacheBlocks, isMallocTest, theThread, &cacheList, &nonCacheList);
}
bool performFree = false;
// Free or save (every other block) for all "cache sized" blocks.
while (!cacheList.IsEmpty()) {
if (performFree) {
FreeBlock(cacheList.LastItem(), sizeOfBlocksInCache, isMallocTest, theThread, &cacheList,
&nonCacheList);
} else {
SaveBlock(theCache, cacheList.LastItem(), sizeOfBlocksInCache, theThread, &cacheList,
&nonCacheList);
}
performFree = !performFree;
}
// Free or save (every other block) for all "non-cache sized" blocks.
while (!nonCacheList.IsEmpty()) {
if (performFree) {
FreeBlock(nonCacheList.LastItem(), sizeOfNonCacheBlocks, isMallocTest, theThread, &cacheList,
&nonCacheList);
} else {
SaveBlock(theCache, nonCacheList.LastItem(), sizeOfNonCacheBlocks, theThread, &cacheList,
&nonCacheList);
}
performFree = !performFree;
}
}
}