当前位置: 首页>>代码示例>>C++>>正文


C++ BList::LastItem方法代码示例

本文整理汇总了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;
		}
	}
}
开发者ID:mariuz,项目名称:haiku,代码行数:57,代码来源:BlockCacheConcurrencyTest.cpp


注:本文中的BList::LastItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。